Michel Schinz | 20 Jan 18:25 2004
Picon
Picon

ANNOUNCEMENT: The Scala Programming Language

We'd like to announce availability of the first implementation of the
Scala programming language.  Scala smoothly integrates object-oriented
and functional programming. It is designed to express common
programming patterns in a concise, elegant, and type-safe way.  Scala
introduces several innovative language constructs. For instance:

- Abstract types and mixin composition unify ideas from object and
  module systems.

- Pattern matching over class hierarchies unifies functional and
  object-oriented data access. It greatly simplifies the processing of
  XML trees.

- A flexible syntax and type system enables the construction of
  advanced libraries and new domain specific languages.

At the same time, Scala is compatible with Java.  Java libraries and
frameworks can be used without glue code or additional declarations.

The current implementation of Scala runs on Java VM. It requires JDK
1.4 and can run on Windows, MacOS, Linux, Solaris, and most other
operating systems. A .net version of Scala is currently under
development.

For further information and downloads, please visit:

    scala.epfl.ch

======================================================================
Martin Odersky and the Scala team,
(Continue reading)

Isaac Gouy | 22 Jan 17:04 2004
Picon

newbie questions - standard loop & catch clause

Thank you all for making Scala available.

1) What is the "standard" way to write a simple loop in
Scala?

   for (val i <- Iterator.range(1,1000000)
or
   var i = 1;
   while (i<=1000000){ ...; i=i+1; }
or
   ?

2) Please show the Scala equivalent catch clause

   val s = "23";
   try { val i =  Integer.parseInt(s); }
   catch (Exception e){ return 1; } }

   try { val i =  Integer.parseInt(s); }
   catch { /* what goes here? */ }

best wishes, Isaac

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/

Michel Schinz | 22 Jan 18:54 2004
Picon
Picon

Re: newbie questions - standard loop & catch clause

Le 22 janv. 04, à 17:04, Isaac Gouy a écrit :

> Thank you all for making Scala available.

Thanks for trying it.

>    for (val i <- Iterator.range(1,1000000)
> or
>    var i = 1;
>    while (i<=1000000){ ...; i=i+1; }
> or
>    ?

Both are fine, but in the current implementation the second one should 
be more efficient.

> 2) Please show the Scala equivalent catch clause
>
>    val s = "23";
>    try { val i =  Integer.parseInt(s); }
>    catch (Exception e){ return 1; } }
>
>    try { val i =  Integer.parseInt(s); }
>    catch { /* what goes here? */ }

You have to use standard pattern matching here (Java's "catch" clauses 
are really nothing more than a limited form of pattern matching). So in 
your case you would put the following:

   catch { case e: Exception => 1 }
(Continue reading)

Stéphane Micheloud | 22 Jan 18:56 2004
Picon
Picon

Re: newbie questions - standard loop & catch clause

My short answer:

1) for-loop:

There is no "standard" way, it mainly depends on what
you want to achieve with your code. Usually you write
'while' for test conditions (i.e. while (x < y) ...)
and 'for' in the other cases. See the examples in
the distribution or in the Scala overview on the Web.

2) try/catch example in Scala:

object test with Application {
   val s = "23";
   val i = try {
     Integer.parseInt(s)
   } catch {
     case _ => 1
   }
   Console.println(i)
}

Have fun !
Stephane

Isaac Gouy wrote:
> Thank you all for making Scala available.
> 
> 1) What is the "standard" way to write a simple loop in
> Scala?
(Continue reading)

Isaac Gouy | 22 Jan 21:39 2004
Picon

Re: newbie questions - standard loop & catch clause

Michel, Stphane, thanks for the quick replies.

> >    for (val i <- Iterator.range(1,1000000)
> >    while (i<=1000000){ ...; i=i+1; }

> the second one should be more efficient

Yes, I noticed that ;-)
And I guess that's the substance of my question.

I'm concerned that I would be mis-representing the language
if I write some silly demonstration programs and those
programs seem slower than other languages. 

And yet, it feels like I would be mis-representing the
language if I write those programs using "while" when it
would be more natural to use the comprehension.

(Guess I'll "do the right thing" and not bother about
performance.)

best wishes, Isaac

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/

Galchin Vasili | 22 Jan 21:41 2004
Picon

Installing on RedHat 9

Hello,

   I just read through the Bug List first before
posting this. An exception is being thrown when I try
to install Scala on ReadHat 9. Below you will see the
backtrace. I will be more than happy to file a bug
report if indeed this is a bug.

Regards, Vasilii

[vigalchin <at> localhost vigalchin]$ sh install.bin
Preparing to install...
Extracting the installation resources from the
installer archive...
Configuring the installer for this system's
environment...

Launching installer...

Warning: -Xmx50331648 not understood. Ignoring.
Warning: -Xms16777216 not understood. Ignoring.
Exception in thread "main" java.lang.InternalError:
Unexpected exception while defining class ZeroGt:
java.lang.ClassNotFoundException: javax.swing.JDialog
   at 0x40268e17:
java.lang.Throwable.Throwable(java.lang.String)
(/usr/lib/./libgcj.so.3)
   at 0x4025bc8e:
java.lang.Error.Error(java.lang.String)
(/usr/lib/./libgcj.so.3)
(Continue reading)

Sébastien Briais | 22 Jan 22:14 2004
Picon

Re: Installing on RedHat 9

Galchin Vasili wrote:
> Hello,
> 
>    I just read through the Bug List first before
> posting this. An exception is being thrown when I try
> to install Scala on ReadHat 9. Below you will see the
> backtrace. I will be more than happy to file a bug
> report if indeed this is a bug.
> 
> Regards, Vasilii

Hi,

are you sure you are using the java distribution from Sun?
(available on java.sun.com)
I guess by default RedHat includes the open source JVM kaffe
of which the standard lib is not completely compatible with
Sun one...

hope this helps

Sébastien

Isaac Gouy | 22 Jan 22:40 2004
Picon

Ord & Double

Seems I'm doing something wrong - how do I write testMethod
so I can use it with Double or Int or Char or anything else
that defines <

object test {
   def main(args: Array[String]) = {
      val n = new Array[Double](10);
      for (val i <- Iterator.range(0,10)) n(i) = 5.0;
      testMethod(n);
   }

   def testMethod[T <: Ord[T]](a: Array[T]): Unit = { }
}

test.scala:5: inferred type arguments [scala.Double] do not
conform to method testMethod's type parameter bounds [T <:
scala.Ord[T]]
      testMethod(n);
                ^

best wishes, Isaac

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/

Matthias Zenger | 22 Jan 23:05 2004
Picon
Picon

Re: Ord & Double

Isaac, you don't do anything wrong. Currently, the class scala.Double
(and all other value classes) are *not* a subclass of scala.Ord. This
is an implementation restriction of our compiler. I'm afraid you have
to use wrappers for now.

== Matthias

On Jan 22, 2004, at 22:40, Isaac Gouy wrote:
> Seems I'm doing something wrong - how do I write testMethod
> so I can use it with Double or Int or Char or anything else
> that defines <
>
> object test {
>    def main(args: Array[String]) = {
>       val n = new Array[Double](10);
>       for (val i <- Iterator.range(0,10)) n(i) = 5.0;
>       testMethod(n);
>    }
>
>    def testMethod[T <: Ord[T]](a: Array[T]): Unit = { }
> }
>
> test.scala:5: inferred type arguments [scala.Double] do not
> conform to method testMethod's type parameter bounds [T <:
> scala.Ord[T]]
>       testMethod(n);
>                 ^
>
> best wishes, Isaac

(Continue reading)

barrv | 23 Jan 06:58 2004
Picon

barr <at> postmail.ch



Gmane