[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What?



In article <000f01c24120$53941dd0$9c8bfd3e@wilde>,
 "Jason Trenouth" <jason.trenouth@bigfoot.com> wrote:

> ----- Original Message -----
> From: "mw" <nsp4@mac.com>
> To: <info-dylan@ai.mit.edu>
> Sent: Sunday, August 11, 2002 2:45 AM
> Subject: What?
> 
> 
> > What is this language? I have never heard of it before.
> 
> One reductionist breakdown might be:
> 
> Dylan = Scheme + CLOS + Smalltalk + Pascal
> 
> Scheme for basic semantics.

What is that exactly? Lisp1, tail-recursion, "?" naming convention for
predicates. What else?

> Common Lisp Object System (CLOS) for the object system, and exception
> handling.

What about: parameter list , keywords, numerics, setters,
multiple values, lots of the library functions, ... ?
Looks a lot like Common Lisp to me.

<..>

To see how near to CL this is:

> // Example: summing a stream of integers
> 
> define method sum-stream ( stream )
>   let sum = 0;
>   let n = #f;
>   while ( n := read-line( stream, on-end-of-stream: #f ) )
>     sum := sum + string-to-integer( n );
>   end;
>   sum
> end;

(defmethod sum-stream ((stream stream))
  (loop for line = (read-line stream nil nil)
        while line sum (parse-integer line)))

> // Example 3: more functional
> 
> define method read-lines ( stream )
>   let collection = make( <stretchy-vector> );
>   let line = #f;
>   while ( line := read-line( stream, on-end-of-stream: #f ) )
>     add!( collection, line );
>   end;
>   collection
> end;
> 
> define method sum-stream ( stream )
>   reduce( \+, map( string-to-integer, read-lines( stream ) ) )
> end;

(defmethod read-lines ((stream stream))
  (loop for line = (read-line stream nil nil)
        while line collect line))

(defmethod sum-stream ((stream stream))
  (reduce #'+ (read-lines stream) :key #'parse-integer))

Let's check it out:

Welcome to Macintosh Common Lisp Version 4.something-i-won't-tell-you!
? (with-input-from-string (stream
"1
2
3
4")
  (sum-stream stream))

10

Hehe, I hear the Gwydion Dylan people are adding more Lisp stuff
to Dylan.


Rainer Joswig