Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #50168
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: CfV: Quotations |
| Date | 2016-08-16 07:13 +0000 |
| Organization | Institut fuer Computersprachen, Technische Universitaet Wien |
| Message-ID | <2016Aug16.091357@mips.complang.tuwien.ac.at> (permalink) |
| References | <2016Aug10.185227@mips.complang.tuwien.ac.at> <87lh041mjx.fsf@jester.gateway.pace.com> <noqlm8$ag1$3@dont-email.me> <87lgzxuwdr.fsf@jester.gateway.pace.com> |
Paul Rubin <no.email@nospam.invalid> writes:
>Bernd Paysan <bernd.paysan@gmx.de> writes:
>> Forth is not a locals-centric language, it's a stack-centric
>> language... Without the stack, quotations would be much less useful.
>
>Locals are optional but I'd hope quotations are even more optional?
I expect quotations to become CORE EXT, so there would be no
requirement to implement locals in order to implement quotations.
There is also no reason to, given that quotations cannot access outer
locals in the proposed quotations.
>> The problem with nested functions is not only that they are more
>> difficult to implement, it's also that they can't outlive their parent's
>> stack frame lifetime, and quotations which do are part of the use cases.
>
>I wonder how often quotations will leave stuff on the stack for use by
>the next iteration of something. I'm used to using a HOF like "fold" or
>"reduce" for that, though it would seem weird in Forth.
Depending on the HOF, but I expect it to happen pretty often for those
that call the xt multiple times. In Forth, you can use the same HOF
for foreach and for reduce.
>If you don't need any mutable global state (like the stack) then you can
>pass parameters into the lambda, which can survive the parent returning.
You can pass parameters through the stacks in addition to keeping
computed values on the stack. Of course, if there are too many,
things become unwieldy. E.g. (untested):
: fmap ( ... addr u xt -- ... )
\ addr u is a floating-point array with u elements starting at addr.
\ call xt ( ... r -- ... ) once for each element r
... ;
2e 0e v vlen [: ( rexp racc r -- rexp racc1 ) 2 fpick f** f+ :] fmap
Bernd Paysan thinks that's good enough. I am not sure. Especially
when working with several HOFs at once, it becomes hard to follow what
happens on the stack. Or maybe it's just that we are not used to
dealing with that.
- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2016: http://www.euroforth.org/ef16/
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
CfV: Quotations anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-08-10 16:52 +0000
Re: CfV: Quotations Matthias Trute <matthias.trute@gmail.com> - 2016-08-10 11:19 -0700
Re: CfV: Quotations Paul Rubin <no.email@nospam.invalid> - 2016-08-10 11:55 -0700
Re: CfV: Quotations Bernd Paysan <bernd.paysan@gmx.de> - 2016-08-14 20:52 +0000
Re: CfV: Quotations hughaguilar96@gmail.com - 2016-08-14 14:42 -0700
Re: CfV: Quotations Julian Fondren <julian.fondren@gmail.com> - 2016-08-14 16:43 -0700
Re: CfV: Quotations Paul Rubin <no.email@nospam.invalid> - 2016-08-15 22:16 -0700
Re: CfV: Quotations anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-08-16 07:13 +0000
Re: CfV: Quotations Paul Rubin <no.email@nospam.invalid> - 2016-08-18 15:30 -0700
Re: CfV: Quotations anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-08-19 15:32 +0000
Re: CfV: Quotations Bernd Paysan <bernd.paysan@gmx.de> - 2016-08-20 20:46 +0000
Re: CfV: Quotations anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-08-21 09:32 +0000
Re: CfV: Quotations hughaguilar96@gmail.com - 2016-08-21 11:06 -0700
Re: CfV: Quotations anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-08-24 17:02 +0000
Re: CfV: Quotations Bernd Paysan <bernd.paysan@gmx.de> - 2016-08-21 22:52 +0000
Re: CfV: Quotations anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-08-22 13:54 +0000
Re: CfV: Quotations Bernd Paysan <bernd.paysan@gmx.de> - 2016-08-22 23:19 +0000
Re: CfV: Quotations anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-08-24 15:54 +0000
Re: CfV: Quotations Bernd Paysan <bernd@net2o.de> - 2016-08-28 00:43 +0000
Re: CfV: Quotations anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-08-28 09:53 +0000
Re: CfV: Quotations Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-08-28 08:32 -0500
Re: CfV: Quotations anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-08-28 14:38 +0000
Re: CfV: Quotations mhx@iae.nl - 2016-08-10 12:02 -0700
Re: CfV: Quotations Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2016-08-11 17:25 +0100
Re: CfV: Quotations Julian Fondren <julian.fondren@gmail.com> - 2016-08-11 12:48 -0700
Re: CfV: Quotations minforth@arcor.de - 2016-08-16 03:31 -0700
Re: CfV: Quotations Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2016-08-31 15:15 +0100
Re: CfV: Quotations anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-08-31 15:26 +0000
Re: CfV: Quotations Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2016-09-02 22:33 +0100
Re: CfV: Quotations anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-09-03 06:47 +0000
csiph-web