Langage differences between TR and mindy 
Author Message
 Langage differences between TR and mindy

-----BEGIN PGP SIGNED MESSAGE-----

Hi,

while trying to get the Skip-List package by Kai Zimmermann working
with mindy, I noticed some differences between TR and mindys ideas
about Dylan. I wonder which one is correct:

- - The TR parses a construct like

        identifier::<type>
  as
        identifier :: <type> ,

  while mindy parses

        identifier: : <type> ;

  which of course results in an syntax error. My understanding is that
  mindy is correct in that case, because parsers are expected to read
  as many characters as possible before matching, and identifier: is
  the longest possible and perfectly legal token in this case.

- - The code contains a class with a construct like this:

        define class <myclass> (<object)
                slot some-slot, init-function: make(<someclass>,
                                                    default: $empty);
                slot next, init-keyword: next-link:;
        end;

        define constant $empty = make(<myclass, next-link: 0);

  The problem with that code is that the initialization of the
  <myclass> object requires a call to make(<myclass>), which can't be
  done because <myclass> isn't initialized yet! The initialization
  can't even be deferred, the latest time for that is just before the
  first call to make(<myclass>), but that in turn requires evaluation
  of $empty, and that is a call to make(<myclass>).

  I don't know how TR handles this, and I don't know if this is legal
  by DRM standards.

Andreas

-----BEGIN PGP SIGNATURE-----
Version: 2.6.2
Comment: Processed by Mailcrypt 3.4, an Emacs/PGP interface

iQCVAgUBMaz9SUyjTSyISdw9AQG42gP/bgLZlbQ5REkrEfRIbOT0IWkVz2Jw5B0s
RO5Kh1FvnNdDoqrwX3j+OfjK40Id+nIKReA3P6ZAHG8Cd0CeIc/xP3c1OMvRhZcE
JYehPECU0A3bJC6fjYta2gV2CMFZAYjszBAO6/EgR/X76GaRc0f59zp5BoPbfURr
uTk4ssnWM4U=
=KDWy
-----END PGP SIGNATURE-----

-- Kallisti!



Mon, 16 Nov 1998 03:00:00 GMT  
 Langage differences between TR and mindy


Quote:
>- - The TR parses a construct like

>    identifier::<type>
>  as
>    identifier :: <type> ,

>  while mindy parses

>    identifier: : <type> ;

>  which of course results in an syntax error.

Mindy is correct.  When in doubt, use whitespace.

[example simplified]

Quote:
>- - The code contains a class with a construct like this:

>    define class <myclass> (<object)
>            slot some-slot = $empty;
>    end;

>    define constant $empty = make(<myclass>);

As far as I know, the restrictions upon the ordering of top-level
forms have never been specified.  Mindy implements a fairly liberal
ordering policy--almost anything is legal.  But not this.  I can't
think of any reasonable policy that would allow circularities like
this one.  (Which leads me to wonder how the TR did it...)

In Mindy, you can kludge around it this way:

        define class <myclass> (<object>)
          slot some-slot;
        end class;

        // This seems to depend on this expression being evaluated before the
        // appropriate method is added to initialize().
        //
        define constant $empty = make(<myclass>);

        define method initialize (obj :: <myclass>,
                                  #next next-method,
                                  #key level: nlevel);
          next-method();
          obj.some-slot := $empty;
        end method;

Again, this is almost certainly *not* legal Dylan, and it is
*definitely* not portable.  And frankly, I'm not entirely sure how it
works in Mindy.  I'm guessing the constant $empty is set up before
this method of initialize is added to the initialize GF.
--

-Nick Kramer



Fri, 27 Nov 1998 03:00:00 GMT  
 Langage differences between TR and mindy


Quote:

> [example simplified]
> >- - The code contains a class with a construct like this:

> >       define class <myclass> (<object)
> >               slot some-slot = $empty;
> >       end;

> >       define constant $empty = make(<myclass>);

> As far as I know, the restrictions upon the ordering of top-level
> forms have never been specified.  Mindy implements a fairly liberal
> ordering policy--almost anything is legal.  But not this.  I can't
> think of any reasonable policy that would allow circularities like
> this one.  (Which leads me to wonder how the TR did it...)

There is no problem of ordering of top-level forms here.  The problem
is an infinite recursion: the init-function for slot some-slot calls
itself indirectly, in effect.

I'm suspicious of the claim that this works in Apple Dylan TR, since
that release does not support the recently-added = sign construct
in slot specifiers.  I tried this equivalent:

define class <myclass> (<object>)
  slot some-slot, init-function: method() $empty end;
end;

define constant $empty = make(<myclass>);

This compiles and runs, but $empty.some-slot is unbound, instead
of being initialized to itself.  I believe this is a bug, not a feature.

Referring to DRM-1 p.63 "Instance Creation and Initialization",
the init-function should be called after making the instance but
before returning the result from make, thus $empty hasn't been
given a value yet when the init-function is first called.  The bug
is likely that there is no unbound variable checking on the reference
to $empty.  Since Dylan doesn't allow variables to be declared without
initializing them, the only way an unbound variable can be seen is
in situations like this one involving circular dependencies in
initialization.  The Apple Dylan TR compiler is a bit erratic about
unbound variable checking.  

It would be unwise to write Dylan code that only works because of
these bugs in Apple Dylan TR.
--Dave Moon



Sun, 29 Nov 1998 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. (langage APL)

2. question sur un langage (APL)

3. An awk langage to C compiler ?

4. Probleme de langage

5. Recherche langage clarion

6. Langage FORTH sur Web - mp7.txt (1/1)

7. Langage FORTH sur Web - mp7.txt (0/1)

8. Clipper versus other langages

9. Connaissez-vous Proparse pour le langage Progress?

10. Formal langage description

11. Clipper langage formal description

12. Sondage: enseignement des langages fonctionnels

 

 
Powered by phpBB® Forum Software