POV-Ray : Newsgroups : povray.off-topic : A silly little toy (~200 kb) Server Time
10 Oct 2024 03:18:21 EDT (-0400)
  A silly little toy (~200 kb) (Message 21 to 27 of 27)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Orchid XP v8
Subject: Re: Build #86 (user-defined functions)
Date: 17 Oct 2008 13:14:44
Message: <48f8c804@news.povray.org>
>> 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

From: Darren New
Subject: Re: Build #86 (user-defined functions)
Date: 17 Oct 2008 13:34:41
Message: <48f8ccb1$1@news.povray.org>
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

From: Orchid XP v8
Subject: Re: Build #86 (user-defined functions)
Date: 17 Oct 2008 13:47:08
Message: <48f8cf9c@news.povray.org>
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

From: Warp
Subject: Re: Build #86 (user-defined functions)
Date: 17 Oct 2008 13:52:44
Message: <48f8d0ec@news.povray.org>
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

From: Darren New
Subject: Re: Build #86 (user-defined functions)
Date: 17 Oct 2008 14:12:58
Message: <48f8d5aa$1@news.povray.org>
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

From: Invisible
Subject: Re: Build #86 (user-defined functions)
Date: 20 Oct 2008 04:06:22
Message: <48fc3bfe@news.povray.org>
> 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

From: Darren New
Subject: Re: Build #86 (user-defined functions)
Date: 20 Oct 2008 11:16:01
Message: <48fca0b1$1@news.povray.org>
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

<<< Previous 10 Messages Goto Initial 10 Messages

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.