gforth
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gforth] Fwd: anonymous inline word definitions


From: Bernd Paysan
Subject: Re: [gforth] Fwd: anonymous inline word definitions
Date: Wed, 05 Dec 2012 15:48:11 +0100
User-agent: KMail/4.8.5 (Linux/3.4.11-2.16-desktop; KDE/4.8.5; x86_64; ; )

Am Mittwoch, 5. Dezember 2012, 09:48:41 schrieb Andrew Haley:
> On 12/05/2012 02:13 AM, John Earnest wrote:
> > Any thoughts about how one would go about doing that portably? With a
> > little sugar and a fairly significant amount of plumbing it would be
> > possible to provide lexical capture of local variables surrounding
> > quotations via such a mechanism.
> 
> We've discussed this at some length on comp.lang.forth; I guess
> you missed it.  It'd be somewhere between difficult and impossible
> to do portably.

It's actually not just about portability.  We don't have *lexical scoping* in 
Forth.  Locals don't have a lexical scope, they have a temporal scope - they 
exist while their surrounding definition is running, and are synchronously 
destroyed with leaving that definition.  The lifetime of quotations is 
indefinite (they are just static pieces of code in the dictionary), therefore, 
it does not make sense to associate some context with them.

During the discussion, someone (forgot who) presented an implementation of 
closures using Mini-OOF, so you can do it, by significantly changing the way 
things are done.

-- 
Bernd Paysan
"If you want it done right, you have to do it yourself"
http://bernd-paysan.de/

Attachment: signature.asc
Description: This is a digitally signed message part.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]