Andrei Formiga | 1 Jan 2006 06:09
Picon

Bug in Windows Installer (1.4.0.3)

   Happy New Year everyone,

   Just a quick note to let know that the windows installer for
version 1.4.0.3 is still broken. After installation, I got these
results:

D:\Test\scala>scalac -version
scalac 1.4.0.3 -- (c) 2002-05 LAMP/EPFL

D:\Test\scala>scalac Hello.scala
error: source file for class Function0 could not be found; source file
for class Function0 is needed
error: source file for class Function1 could not be found; source file
for class Function1 is needed
error: source file for class Function2 could not be found; source file
for class Function2 is needed
error: source file for class Function3 could not be found; source file
for class Function3 is needed
error: source file for class Function4 could not be found; source file
for class Function4 is needed
error: source file for class Function5 could not be found; source file
for class Function5 is needed
error: source file for class Function6 could not be found; source file
for class Function6 is needed
error: source file for class Function7 could not be found; source file
for class Function7 is needed
error: source file for class Function8 could not be found; source file
for class Function8 is needed
error: source file for class Function9 could not be found; source file
for class Function9 is needed
(Continue reading)

Philippe Altherr | 5 Jan 2006 14:53
Picon
Picon
Favicon

Re: Scala type system questions -- representing the concept of monadsin Scala

Vijay Saraswat wrote:
> 
> A proof would be very welcome!

Here is one but it's a proof of the contrary. The file "Monad.scala"
defines the "Monad", the "MonadZero" and the "MonadPlus" and gives
three implementation of the MonadPlus: "Option", "List" and
"Stream". "Option" is a "lossy" version of "MonadPlus" as it remembers
only the first value. "Stream" is a lazy version of List.

The file contains also a test program. It consists of a function which
given a (non-lossy) "MonadPlus" resolves the n-queens problem for
different board sizes. This function is called once with "List" and
once with "Stream". The result is provided in the file "Monad.txt".

As Martin explained in his mail, constructor polymorphism is needed to
express monads and Scala does not support constructor
polymorphism. However, mainly due to a bug, Scala supports the
refinement of abstract type members and this happens to be equivalent
to constructor polymorphism. This implementation of monads relies
entirely on this "bug" or more precisely on the ability to write types
of the form "T { type X = ... }" where T is a type member.

This "bug" is present in the distributed Scala compiler but programs
which exploit it usually cause a crash of the compiler's back-end or
are compiled into non-functional class files. That's why the program
can't be compiled with the current Scala distribution but it works
with the new compiler which "supports" the same "bug" but in a much
more robust way. The new compiler is not yet publicly distributed but
it seems that a beta should soon be available.
(Continue reading)

Michael Benfield | 9 Jan 2006 23:25
Picon

Re: "class" identifier


On Jan 9, 2006, at 3:54 PM, Eyer Leander wrote:
>
> The wrapper method "SomeClassName.getClass()" should work, it returns 
> the class object as well.
>

Nope. See here:

-------------
$ cat Wrapper.scala

import javax.sound.sampled.SourceDataLine;

class Wrapper {
     def something() = SourceDataLine.getClass();
}

$ scalac Wrapper.scala
Wrapper.scala:5: value getClass is not a member of 
javax.sound.sampled.SourceDataLine
     def something() = SourceDataLine.getClass();
                                     ^
one error found

---------------

Maybe SourceDataLine doesn't have the getClass method because 
SourceDataLine is a class and not an object?

(Continue reading)

Jamie Webb | 9 Jan 2006 23:54

Re: "class" identifier

On Mon, Jan 09, 2006 at 03:28:28PM -0500, Michael Benfield wrote:
> I've never used Java, but apparently "class" is a valid identifier 
> there, as I need to interact with some Java code where I am expected to 
> say "SomeClassName.class". In Scala, that doesn't work. Is there any 
> way to do this directly from Scala? I've written a little Java wrapper 
> to do it for me, but it'd be nice to be able to toss out the extra 
> file.

You can use Class.forName("some.package.SomeClassName"). I think Scala
doesn't support the .class notation because there is not a 1:1 mapping
between Scala class names and the emitted Java class objects, so it
would often not do what you want.

> Also, just out of curiosity... What's up with this mailing list? I 
> think I subscribed about a week ago and have seen one message on the 
> list so far. Scala seems to be a living language but the list seems all 
> but dead. Is there some other place where the Scala community talks?

Traffic comes and goes. I get the impression that although Scala is
being actively developed, there are not that many users outside EPFL,
and many of them are at other universites. The christmas holidays
probably end about now?

-- Jamie Webb

Michael Benfield | 9 Jan 2006 21:28
Picon

"class" identifier

I've never used Java, but apparently "class" is a valid identifier 
there, as I need to interact with some Java code where I am expected to 
say "SomeClassName.class". In Scala, that doesn't work. Is there any 
way to do this directly from Scala? I've written a little Java wrapper 
to do it for me, but it'd be nice to be able to toss out the extra 
file.

Also, just out of curiosity... What's up with this mailing list? I 
think I subscribed about a week ago and have seen one message on the 
list so far. Scala seems to be a living language but the list seems all 
but dead. Is there some other place where the Scala community talks?

Thanks,
Mike Benfield

Michael Benfield | 10 Jan 2006 23:24
Picon

Re: "class" identifier


On Jan 9, 2006, at 5:54 PM, Jamie Webb wrote:
>
> You can use Class.forName("some.package.SomeClassName").

Thanks!

Mike Benfield

Michael Benfield | 10 Jan 2006 23:35
Picon

weird asInstanceOf issue

I'm getting a ClassCastException in a very specific situation when 
trying to convert a float to an int with asInstanceOf:

-----------

$ cat MyTest.scala

object MyTest {
     def main(args: Array[String]) = {
         var f: float = 0f;
         for(val x <- Iterator.range(0, 0))
             f = f + 1.5f;
         val i: int = f.asInstanceOf;
         System.out.println(i);
     }

}
$ scalac MyTest.scala
$ scala MyTest
Exception in thread "main" java.lang.ClassCastException
         at MyTest$.main(MyTest.scala:7)
         at MyTest.main(MyTest.scala:3)

----------

If I change "asInstanceOf" to "toInt", it works. What's weirdest is 
that the for loop isn't doing anything, but if I remove it, it works. 
If I change the for loop so that its body doesn't involve f, it works. 
I can't imagine why since it shouldn't be doing anything to f anyway.

(Continue reading)

Eyer Leander | 9 Jan 2006 21:54
Picon
Picon
Favicon

Re: "class" identifier

Hello Michael

The wrapper method "SomeClassName.getClass()" should work, it returns 
the class object as well.

Regards
  Leander Eyer

Michael Benfield wrote:

> I've never used Java, but apparently "class" is a valid identifier 
> there, as I need to interact with some Java code where I am expected 
> to say "SomeClassName.class". In Scala, that doesn't work. Is there 
> any way to do this directly from Scala? I've written a little Java 
> wrapper to do it for me, but it'd be nice to be able to toss out the 
> extra file.
>
> Also, just out of curiosity... What's up with this mailing list? I 
> think I subscribed about a week ago and have seen one message on the 
> list so far. Scala seems to be a living language but the list seems 
> all but dead. Is there some other place where the Scala community talks?
>
> Thanks,
> Mike Benfield
>

Clive Jevons | 11 Jan 2006 15:41
Picon
Favicon

Question about changing attributes on Elem's in XML documents

Hi there,

I was wondering what the best way to add an attribute to an element  
in an existing XML tree would be.
I'm wanting to do something like this:

import scala.io.Source;
import scala.xml.parsing.ConstructingParser;
import scala.xml._;

object attributeTest {

	def main (args: Array[String]): Unit = {
		val myXml = ConstructingParser.fromSource(Source.fromFile 
("test.xml"), true);
		val doc = myXml.document();
		for (val node: Node <- doc.children) node match {
			case e: Elem =>
				e.attributes.append(new UnprefixedAttribute("test", "test", null)
			case _ => ;
		}
	}

}

Now, obviously, that code isn't going to work - its just meant to  
demonstrate my intentions ;)
The main problem I'm struggling with (possibly because I haven't done  
any real functional programming before?) is that neither the children  
sequence on the elements nor the attribute sequence on elements  
(Continue reading)

Stéphane Micheloud | 11 Jan 2006 18:21
Picon
Picon
Favicon

[ANN] Beta version of Scala 2


We'd like to announce availability of the BETA version of Scala 2,
a new implementation of the Scala programming language.

The Scala 2 compiler has been rewritten from scratch in Scala itself.
It compiles more or less the same language as the old one.

Changes between Scala version 1.0 and 2.0 include:

     * There are four new keywords.
     * Newlines can now be used as statement separators,
       making semicolons optional.
     * Some old syntax constructs are no longer legal.
     * The recommended syntax of selftype annotations has changed.
     * The implicit conversion rules from methods to values have changed.
     * Getters and setters can now be generated for class parameters.
     * Visibility of classes and their members can now be restricted
       in more finegrained ways.
     * The model of mixin composition has changed.
     * Views have been replaced by a new concept of implicit parameters.
     * Typing rules for pattern matching have been relaxed.

Please refer to the following document for a detailed description
of the changes:

      http://scala.epfl.ch/nsc/files/Changes.pdf

For further information and downloads, please visit:

      http://scala.epfl.ch/
(Continue reading)


Gmane