Newsgroups: comp.lang.dylan
Path: cantaloupe.srv.cs.cmu.edu!rochester!udel!news.sprintlink.net!noc.netcom.net!netcom.com!netcom9.netcom.com!haahr
From: haahr@netcom.com (Paul Haahr)
Subject: Re: Questions
In-Reply-To: Wolfgang Ziller's message of 28 Oct 1995 15:18:19 GMT
To: Wolfgang Ziller <wziller@math.upenn.edu>
Message-ID: <HAAHR.95Oct30160423@netcom9.netcom.com>
Sender: haahr@netcom9.netcom.com
Organization: NETCOM On-line services
References: <46mlhk$huh@netnews.upenn.edu> <HAAHR.95Oct27125805@netcom9.netcom.com>
	<46thjr$jid@netnews.upenn.edu>
Date: Mon, 30 Oct 1995 16:04:23 GMT
Lines: 70

Wolfgang Ziller <wziller@math.upenn.edu> wrote:
> >> 1)  Since dylan allows multiple return values, why can't 
> >> these values returned be assigned to variables already 
> >> declared?
> >
> >Because the ``multiple value assignment'' proposal was never accepted.
> >It could certainly be added to the language at some later date.
> 
> What was the reasoning for not accepting it?

It fell by the waysides when some bigger issues -- notably, the macro
system -- were being worked out.  I don't think anyone considered it an
important enough issue to hold up the DRM for.

> >> 2)  How do I pass values to a function by reference (so 
> >> that the variable passed in can change value).  Dylan seems 
> >> to use pass by value...I want the equivalent of Pascal's 
> >> var statement (or c's & operator).
> >
> >You can't.  Use multiple values or (when they are available) macros.
> 
> So this forces me to use multiple values.

For what?  Side-effecting the contents of an object causes the change to
be visible to all users of the object.  It's just changing what object a
name is bound to that you can't do.

That is, this causes no change to *the-counter*:

  define variable *the-counter* = 0;

  define method increment (counter :: <integer>) => ()
    counter := counter + 1;  // insensible in Dylan
  end method increment;

  increment(*the-counter*);  // doesn't do anything

whereas this does increment a slot in *the-counter*:

  define class <counter> (<object>)
    slot value = 0;
  end class <counter>;

  define constant *the-counter* = make(<counter>);

  define method increment (counter :: <counter>) => ()
    counter.value := counter.value + 1;
  end method increment;

  increment(*the-counter*);

> I can see the Dylan programming paradigm is quite different from that
> of C++ or Eiffel.

Not that different from Eiffel, certainly.  I believe Eiffel's argument
passing semantics are the same as Dylan's.  Some people call that
something other than ``call by value,'' but I'm pretty sure there's no
difference in  the semantics.

> I guess this means that global variables aren't used quite as much in
> Dylan (because to change the value of a global variable based on the
> output of a function, one must create temporary variables and then
> assign the global variables to these temp vars).

Global variables are used pretty rarely in many languages;  lots of
people think using them is bad style, etc.  But I don't see any major
differences between Dylan's global variables and those in C or C++,
other than you can't take the address of a Dylan variable.

Paul
