Related articles |
---|
Questions about anonymous functions and classes/functions declarations mrfaro@libero.it (Gabriele Farina) (2003-10-04) |
Re: Questions about anonymous functions and classes/functions declar daniel_yokomiso@yahoo.com.br (Daniel Yokomiso) (2003-10-06) |
Re: Questions about anonymous functions and classes/functions declarat derkgwen@HotPOP.com (Derk Gwen) (2003-10-06) |
Re: Questions about anonymous functions and classes/functions declarat lsantil@calstatela.edu (Louis Paul Santillan) (2003-10-06) |
Re: Questions about anonymous functions and classes/functions declarat haberg@matematik.su.se (2003-10-06) |
Re: Questions about anonymous functions and classes/functions declarat joachim.durchholz@web.de (Joachim Durchholz) (2003-10-06) |
Re: Questions about anonymous functions and classes/functions declarat geoff@wozniak.ca (Geoff Wozniak) (2003-10-08) |
[3 later articles] |
From: | "Gabriele Farina" <mrfaro@libero.it> |
Newsgroups: | comp.compilers |
Date: | 4 Oct 2003 14:35:41 -0400 |
Organization: | TIN |
Keywords: | design |
Posted-Date: | 04 Oct 2003 14:35:41 EDT |
Hi guys,
I'm planning to try to implemente a programming language. I got a lot
of ideas, and I know how to implements them except for anonymous
functions. Where I have to store them?? I have to have a table only
for anonymous functions?? Someone asks to me to treat them as
constants, but I can't understanda how to develop it.
Now there is another questions: I'd like to give the users the ability
to edit a class definition at runtime. For example:
test = class()
input value
if value == 10
test.a_new_method = function(a) print a
else
test.a_new_method = function(a) print 'Your wrong the number, you
inserted'.append(a)
instance = new test()
instance.a_new_method(value)
This little piece of code is useless, I know, but I write it to make you
understand what I'd like to do.
test = class() defines a new class, where, dynamically, I add a new method
looking at a variable value given as input.
As you can see I add new method at runtime.
Do you think this can be useful and can be implemented?? There could be any
problems??
thanks a lot, I hope you understand my questions.
bye
[The only way I know to handle anonymous functions is to give each on a
secret private name at compile time. As far as adding new methods at
runtime, it's doable but it means that you have to keep most of the
compiler symbol table at runtime and possibly the whole compiler if
you're adding new code on the fly. -John]
Return to the
comp.compilers page.
Search the
comp.compilers archives again.