Related articles |
---|
[16 earlier articles] |
Re: The compilation approach in modern languages jle@ural.owlnet.rice.edu (2005-02-20) |
Re: The compilation approach in modern languages gneuner2@comcast.net (George Neuner) (2005-02-28) |
Re: The compilation approach in modern languages anton@mips.complang.tuwien.ac.at (2005-02-28) |
Re: The compilation approach in modern languages gneuner2@comcast.net (George Neuner) (2005-03-01) |
Re: The compilation approach in modern languages boldyrev@cgitftp.uiggm.nsc.ru (Ivan Boldyrev) (2005-03-04) |
Re: The compilation approach in modern languages anton@mips.complang.tuwien.ac.at (2005-03-05) |
Re: The compilation approach in modern languages hannah@schlund.de (2005-05-18) |
From: | hannah@schlund.de (Hannah Schroeter) |
Newsgroups: | comp.compilers |
Date: | 18 May 2005 12:17:33 -0400 |
Organization: | Schlund + Partner AG |
References: | 05-02-05305-02-077 05-02-080 05-02-090 |
Keywords: | functional |
Posted-Date: | 18 May 2005 12:17:32 EDT |
Hello!
George Neuner <gneuner2@comcast.net> wrote:
>On 18 Feb 2005 22:49:12 -0500, hannah@schlund.de (Hannah Schroeter)
>wrote:
>>George Neuner <gneuner2@comcast.net> wrote:
>>>[...]
>>>Most (all?) of the recognized functional languages allow functions to
>>>be redefined and anonymous functions to be created, but I don't know
>>>whether they routinely permit the same kind of run time extension
>>>possible in Lisp.
>>Redefinition? When I look at Haskell, SML or ocaml, I don't see a way
>>to redefine functions (in the sense that you can, at run time, change
>>the definition).
>Terminology? I didn't mean a function can be changed, I meant that
>its name can be re-bound to a different function (possibly eliminating
>all references to the first function).
You can't re-bind (global) names in *ML or Haskell. You can use different
parameters on a parameter position with a function type, you can change
reference cells in *ML/Haskell. I.e. you can use values with a function
type. They're usually represented as lexical closure, often represented
as a pointer to code, plus a pointer to the captured lexical environment,
or similar.
Not much hassle to compilers.
And in Lisp, yeah, you can dynamically compile code
(compile 'nil (lambda ...))
yields an object of type function. That object can also be represented
as closure (see above), where the code pointer points to a newly allocated
code block where the compile function wrote its object code (be it
byte code, be it native machine code).
The binding of global function names to the code is done using the
function cell of symbols in Common Lisp, which also references any
object of type function, i.e. you can use any closure there. Usually
the environment part of those closures are empty (e.g. if you use defun
not inside a lexical binding to create a function with a symbolic name).
>George
Kind regards,
Hannah.
Return to the
comp.compilers page.
Search the
comp.compilers archives again.