Re: Grammars for future languages

Eric Gouriou <egouriou@CS.UCLA.EDU>
Thu, 16 Nov 1995 08:32:03 GMT

          From comp.compilers

Related articles
[12 earlier articles]
Re: Grammars for future languages davids@ICSI.Berkeley.EDU (1995-11-10)
Re: Grammars for future languages macrakis@osf.org (1995-11-10)
Re: Grammars for future languages mfinney@inmind.com (1995-11-12)
Re: Grammars for future languages RWARD@math.otago.ac.nz (Roy Ward) (1995-11-13)
Re: Grammars for future languages macrakis@osf.org (1995-11-13)
Re: Grammars for future languages rekers@wi.leidenuniv.nl (1995-11-14)
Re: Grammars for future languages egouriou@CS.UCLA.EDU (Eric Gouriou) (1995-11-16)
Re: Grammars for future languages sethml@dice.ugcs.caltech.edu (1995-11-21)
| List of all articles for this month |

Newsgroups: comp.compilers
From: Eric Gouriou <egouriou@CS.UCLA.EDU>
Keywords: syntax
Organization: UCLA Computer Science Dpt
References: 95-10-103 95-10-140 95-11-048 95-11-085
Date: Thu, 16 Nov 1995 08:32:03 GMT

Alex Martelli <martelli@cadlab.it> wrote:
  >I'm curious -- is this notion of non-alphanumeric notation
  >as systematic syntactic sugar for well-defined alphanumeric
  >notation an independent inversion of you and Ousterhout
  >(the Father of Sather:-), derived from a common, older
  >source, or what...? Other languages using it...?


  Dylan is using it, but with a different meaning of alphanumeric :-)


  Example:
    a + b is equivalent to \+(a,b)
    (note that + can be used in identifiers, ex: let a+b = a + b; )
    object.slot := b is equivalent to slot-setter(object,b)
    object.slot is equivalent to slot(object)
    a[i] is equivalent to element(a,i)
    a[i] := b is equivalent to element-setter(a,i)


>From the Dylan Reference Manual:
-----------------------------------------
Operations that retrieve a value from a location are called getters.
Operations that store into a location are called setters. In general,
getters and setters come in pairs. Setter binding names are derived by
appending "-setter" to the corresponding getter binding name. This
convention is used to generate setter names automatically, and it is
used by :=, the assignment operator, to find the setter that corresponds
to a given getter.
------------------------------------------
The escape character ( \ ) followed by any name or operator-nam
e has the same meaning as that name or operator-name, except that it is
stripped of special syntactic properties. If it would otherwise be a
reserved word or operator, it is not recognized as such.


For example, \if and if are names for the same binding, but \if is
treated syntactically as a named value reference, while if is the beginning
of a statement. Similarly, \+ and + refer to the same binding, but the
former is treated syntactically as a named value reference, and the latter
as an operator.
------------------------------------------
Dylan provides a shorthand syntax for functions which accept one argument.
The syntax argument.function applies function to argument. This syntax is
commonly used for slot reference, to access the function slot of argument.


Order of execution aside, the following pairs of function calls are
equivalent:
      america.capital and capital(america)
      window.position and position(window)
-------------------------------------------
Dylan provides a shorthand syntax for element reference. The syntax
sequence[i] is equivalent to the function call
element(sequence, i). The syntax array[i1, i2, ... in] is equivalent to the
function call aref(array, i1, i2, ... in).


Order of execution aside, the following pairs of expressions are
equivalent:
  *all-windows*[0] and element(*all-windows*, 0)
  *tic-tac-toe*[1, 2] and aref(*tic-tac-toe*, 1, 2)


The names element and aref are looked up in the environment
of the element reference expression.
------------------------------


  Eric Gouriou
  egouriou@cs.ucla.edu
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.