|Explicit or implicit declaration and inference email@example.com (Avatar) (2006-10-19)|
|Re: Explicit or implicit declaration and inference firstname.lastname@example.org (2006-10-21)|
|From:||email@example.com (Hans Aberg)|
|Date:||21 Oct 2006 02:28:09 -0400|
"Avatar" <firstname.lastname@example.org> 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)
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).
Return to the
Search the comp.compilers archives again.