- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Re: Case classes and the scala interpreter
Tue, 2009-01-06, 13:32
>>>>> "john" == john kemp writes:
john> I set my $classpath appropriately...
I'm not able to reproduce your problem with the information given.
Perhaps your classpath isn't set as appropriately as you think it is...?
Not sure. I'd suggest showing us step by step how to reproduce the
issue from scratch, leaving out nothing.
Tue, 2009-01-06, 15:17
#2
Re: Case classes and the scala interpreter
On Tue, Jan 06, 2009 at 08:29:42AM -0500, john kemp wrote:
> Although I'm grateful that you would show quite such interest, I already
> have a workaround to use the interpreter (simply change the import
> statement as shown above). I was more asking whether it is expected
> behaviour that a case class would not show up in scope when I explicitly
> import that case class into a scala script and use the interpreter.
Given that that's not what happens, I would call it unexpected.
I think he was suggesting you be specific because it's apparent your problem is not what you think it is.
> Are you saying that you know you are able to import a case class from a
> package into a scala script?
Yes.
> Abstractly, the way to check would be to create a package containing at
> least one class, and at least one case class (these two classes defined in
> the same file). Then write a script which imports the class and the case
> class from the package explicitly, and run that script with 'scala
> script.scala'.
"Abstractly" is really not the best way to report perceived bugs. Concretely, what you describe works fine.
Tue, 2009-01-06, 15:37
#3
Re: Case classes and the scala interpreter
>>>>> "john" == john kemp writes:
john> Are you saying that you know you are able to import a case class
john> from a package into a scala script?
Yes:
~/kemp> cat A.scala
package p
case class A
class B
~/kemp> /usr/local/scala-2.7.2.final/bin/scalac A.scala
~/kemp> cat script.scala
import p.A
println(A())
~/kemp> /usr/local/scala-2.7.2.final/bin/scala script.scala
A()
Hi Seth,
Thanks for responding.
On Jan 6, 2009, at 7:31 AM, Seth Tisue wrote:
>>>>>> "john" == john kemp writes:
>
> john> I set my $classpath appropriately...
>
> I'm not able to reproduce your problem with the information given.
> Perhaps your classpath isn't set as appropriately as you think it
> is...?
With the same classpath I am able to do a static compile. And when I
simply change the import statement to be less specific (httpd._
instead of httpd.Incoming) I am also able to use the interpreter to
run the script.
>
> Not sure. I'd suggest showing us step by step how to reproduce the
> issue from scratch, leaving out nothing.
Although I'm grateful that you would show quite such interest, I
already have a workaround to use the interpreter (simply change the
import statement as shown above). I was more asking whether it is
expected behaviour that a case class would not show up in scope when I
explicitly import that case class into a scala script and use the
interpreter.
Are you saying that you know you are able to import a case class from
a package into a scala script?
Abstractly, the way to check would be to create a package containing
at least one class, and at least one case class (these two classes
defined in the same file). Then write a script which imports the class
and the case class from the package explicitly, and run that script
with 'scala script.scala'.
I am running Scala 2.7.2.final on Mac OS X FWIW.
Thanks again for the help.
Regards,
- johnk