|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
>> What is "gensym", and why does Lisp have it?
>
> It creates a guaranteed-unique variable name that you can use as a local
> in a macro or a dynamically-scoped function. What did you *think* it
> might be for, given the bit I quoted and the name of the LISP function?
Mmm, OK.
This isn't hard to do in Haskell - it's just that you have to remember
to do it! (And more subtly, do it at the correct moment.)
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Orchid XP v8 wrote:
> This isn't hard to do in Haskell - it's just that you have to remember
> to do it! (And more subtly, do it at the correct moment.)
Yep. Of course, in LISP, you do this all the time. When you're good at
it, about 30% of your code winds up being code-generating macros. So
figuring out where gensym goes is like figuring out whether you need
global or stack-based variables in a block-structured language. You just
crash and burn if you don't learn it.
--
Darren New / San Diego, CA, USA (PST)
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Darren New wrote:
> Orchid XP v8 wrote:
>> This isn't hard to do in Haskell - it's just that you have to remember
>> to do it! (And more subtly, do it at the correct moment.)
>
> Yep. Of course, in LISP, you do this all the time. When you're good at
> it, about 30% of your code winds up being code-generating macros.
Heh. Crazy language... I thought computer science experts concluded,
like, 30 years ago that self-modifying code is actually an Extremely Bad
Idea? (Originally of course everybody thought it was "cool"...)
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Orchid XP v8 <voi### [at] devnull> wrote:
> Heh. Crazy language... I thought computer science experts concluded,
> like, 30 years ago that self-modifying code is actually an Extremely Bad
> Idea? (Originally of course everybody thought it was "cool"...)
Code generation is not the same thing as self-modifying code.
--
- Warp
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Orchid XP v8 wrote:
> Heh. Crazy language... I thought computer science experts concluded,
> like, 30 years ago that self-modifying code is actually an Extremely Bad
> Idea? (Originally of course everybody thought it was "cool"...)
It's only "self-modifying code" if you modify it after it has already
been run.
Computer scientists quite like code-generating macros. They have some
pretty sophisticated ones, called "compilers".
--
Darren New / San Diego, CA, USA (PST)
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> It's only "self-modifying code" if you modify it after it has already
> been run.
Well, technically that's true. But Lisp macros run at runtime, not
compile time, so technically you could run the same macro twice and have
it generate different code each time...
> Computer scientists quite like code-generating macros. They have some
> pretty sophisticated ones, called "compilers".
Yeah. And as I understand it, writing one is supposedly the hardest task
in all of Computer Science. :-P
Sounds like writing one as part of your application is an excellent idea...
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Invisible wrote:
>> It's only "self-modifying code" if you modify it after it has already
>> been run.
>
> Well, technically that's true. But Lisp macros run at runtime, not
> compile time, so technically you could run the same macro twice and have
> it generate different code each time...
But the macro still doesn't modify the code after that code is run, so
that's OK. Having the same macro generate different code at different
places is the point of a macro.
> Yeah. And as I understand it, writing one is supposedly the hardest task
> in all of Computer Science. :-P
Certainly it used to be before the theories were worked out. Writing one
that generates anything close to optimal code is difficult given the
complexity of current chips.
> Sounds like writing one as part of your application is an excellent idea...
Yep. ;-)
--
Darren New / San Diego, CA, USA (PST)
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |