Re: Explicit or implicit declaration and inference

haberg@math.su.se (Hans Aberg)
21 Oct 2006 02:28:09 -0400

          From comp.compilers

Related articles
Explicit or implicit declaration and inference acampbellb@hotmail.com (Avatar) (2006-10-19)
Re: Explicit or implicit declaration and inference haberg@math.su.se (2006-10-21)
| List of all articles for this month |

From: haberg@math.su.se (Hans Aberg)
Newsgroups: comp.compilers
Date: 21 Oct 2006 02:28:09 -0400
Organization: Mathematics
References: 06-10-071
Keywords: design
Posted-Date: 21 Oct 2006 02:28:09 EDT

"Avatar" <acampbellb@hotmail.com> wrote:


> I am designing a dynamic object-oriented interpreted programming
> language. I have some questions concerning the implementation of
> dynamic variables.
....
> ...what if variables in Ruby did not use a strict naming convention
> for variable classes? How would the compiler know which instructions to
> generate (get: local, global, class, or instance)?


Just make it into a declarative language. One then writes (say)
  constant <name1>
  variable <name2>
  class <name3>
and so on. The implementation is straightforward. When a definition of a
name comes by, store on the lookup table that the lexer checks, also its
grammatical type (constant, variable, class, etc.), which the lexer
returns to the parser. It does not really matter whether the type is
dynamic or not - that is a question for the compiler/interpreter to figure
out a suitable implementation. It is also possible to mix dynamic and
static types. For example:
  string x  = ...  -- Static type.
  variable y.      -- Dynamic type.
  y := x.          -- Always valid.
  x := y.  -- Requires either a check and/or conversion of types, which
           -- can be dynamic or static (static check would make it illegal).


--
    Hans Aberg



Post a followup to this message

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