Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #40522
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: local variable |
| Date | 2015-07-11 13:42 +0000 |
| Organization | Institut fuer Computersprachen, Technische Universitaet Wien |
| Message-ID | <2015Jul11.154246@mips.complang.tuwien.ac.at> (permalink) |
| References | (6 earlier) <mnof8f$tst$1@dont-email.me> <ebe5f448-5311-4949-83c8-e420c71e7080@googlegroups.com> <mnoo9j$1ck$1@dont-email.me> <40c66af5-0dab-46b6-aafe-60aad5b38337@googlegroups.com> <mnosts$jps$1@dont-email.me> |
"Alex McDonald" <blog@rivadpm.com> writes:
>C++ has closures but no GC
>http://www.cprogramming.com/c++11/c++11-lambda-closures.html
They are not fully capable closures, although C++ tries to give you as
much as is possible without requiring GC; the section "How are Lambda
Closures Implemented?" are most enlightening in this respect: So you
can capture referenced variables by-reference (i.e., you access the
original variable through a pointer), but then you must not pass the
lambda outside the scope(s) of the captured variables; or you can
capture the variable by making a copy, then any changes to the
captured variable do not affect the original or any other lamda that
also captures the original variable.
Both options fall short of the power of full-blown closures; e.g., you
cannot implement objects based on C++ lambdas, which you can do with
full-blown closures.
Both options have been proposed as ways to allow outer locals in
Forth. I think we will have to see whether these options give enough
benefit to justify their implementation cost.
>> It's about high order words (like "map", "filter", "apply", etc. see
>> Oforth, see Factor) in strong relation with data structures.
>
>I get that, but I was wondering what the benefit of using outer locals in
>quotations might be.
If the higher-order word calls a word with the stack effect n1 -- n2,
and you want to pass additional arguments, it would be nice if you
could pass these arguments through a local variable; e.g.
( addr u ) [: n + ;] foreach
Bernd Paysan thinks we don't need that, and that we can use the stack
for passing additional stuff; so here we would do it as follows:
n ( addr u ) [: over + ;] foreach drop
I am not convinced that this is good enough in every case, but the
question is if the cases where this technique is too cumbersome or
impossible are frequent enough to matter. I think we should go with
it for a while, until we know where the limits of this technique are.
- 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 2015: http://www.mpeforth.com/euroforth2015/euroforth2015.htm
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: local variable hughaguilar96@gmail.com - 2015-07-04 19:52 -0700
Re: local variable "Alex McDonald" <blog@rivadpm.com> - 2015-07-05 07:24 +0100
Re: local variable Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-05 02:04 -0700
Re: local variable "Alex McDonald" <blog@rivadpm.com> - 2015-07-05 10:36 +0100
Re: local variable Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-05 03:25 -0700
Re: local variable Bernd Paysan <bernd.paysan@gmx.de> - 2015-07-05 15:28 +0200
Re: local variable Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-05 08:11 -0700
Re: local variable Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-05 08:21 -0700
Re: local variable Bernd Paysan <bernd.paysan@gmx.de> - 2015-07-05 23:53 +0200
Re: local variable Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-05 20:31 -0700
Re: local variable hughaguilar96@gmail.com - 2015-07-05 19:56 -0700
Re: local variable hughaguilar96@gmail.com - 2015-07-05 19:57 -0700
Re: local variable "Alex McDonald" <blog@rivadpm.com> - 2015-07-06 08:09 +0100
Re: local variable hughaguilar96@gmail.com - 2015-07-06 19:59 -0700
Re: local variable "Alex McDonald" <blog@rivadpm.com> - 2015-07-07 08:30 +0100
Re: local variable Michael Barry <barrym95838@yahoo.com> - 2015-07-10 00:35 -0700
Re: local variable Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-10 01:41 -0700
Re: local variable "Alex McDonald" <blog@rivadpm.com> - 2015-07-10 13:55 +0100
Re: local variable Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-10 07:13 -0700
Re: local variable "Alex McDonald" <blog@rivadpm.com> - 2015-07-10 16:29 +0100
Re: local variable Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-10 08:57 -0700
Re: local variable "Alex McDonald" <blog@rivadpm.com> - 2015-07-10 17:48 +0100
Re: local variable Paul Rubin <no.email@nospam.invalid> - 2015-07-10 10:02 -0700
Re: local variable "WJ" <w_a_x_man@yahoo.com> - 2015-09-16 17:30 +0000
Re: local variable Mark Wills <markwills1970@gmail.com> - 2015-07-10 10:28 -0700
Re: local variable "Elizabeth D. Rather" <erather@forth.com> - 2015-07-10 08:00 -1000
Re: local variable hughaguilar96@gmail.com - 2015-07-10 21:31 -0700
Re: local variable "Alex McDonald" <blog@rivadpm.com> - 2015-07-10 19:13 +0100
Re: local variable "Elizabeth D. Rather" <erather@forth.com> - 2015-07-10 09:06 -1000
Re: local variable anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-07-11 14:10 +0000
Re: local variable humptydumpty <ouatubi@gmail.com> - 2015-07-11 10:14 -0700
Re: local variable anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-07-12 15:56 +0000
Re: local variable humptydumpty <ouatubi@gmail.com> - 2015-07-12 11:48 -0700
Re: local variable Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-10 21:21 -0700
Re: local variable hughaguilar96@gmail.com - 2015-07-10 21:56 -0700
Re: local variable "Alex McDonald" <blog@rivadpm.com> - 2015-07-11 23:51 +0100
Re: local variable anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-07-11 13:42 +0000
Re: local variable franck.bensusan@gmail.com - 2015-07-12 02:17 -0700
Re: local variable anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-07-12 15:12 +0000
Re: local variable franck.bensusan@gmail.com - 2015-07-13 02:37 -0700
Re: local variable anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-07-13 16:13 +0000
Re: local variable franck.bensusan@gmail.com - 2015-07-13 14:48 -0700
Re: local variable anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-07-14 06:41 +0000
Re: local variable franck.bensusan@gmail.com - 2015-07-14 01:44 -0700
Re: local variable Bernd Linsel <bl1@gmx.com> - 2015-07-11 11:03 +0200
Re: local variable Bernd Linsel <bl1@gmx.com> - 2015-07-11 11:11 +0200
Re: local variable hughaguilar96@gmail.com - 2015-07-12 16:43 -0700
Re: local variable anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-07-11 15:14 +0000
Re: local variable Julian Fondren <julian.fondren@gmail.com> - 2015-07-11 17:57 -0700
Re: local variable anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-07-12 15:32 +0000
Re: local variable "Alex McDonald" <blog@rivadpm.com> - 2015-07-10 13:13 +0100
Re: local variable hughaguilar96@gmail.com - 2015-07-10 21:48 -0700
Re: local variable franck.bensusan@gmail.com - 2015-07-05 03:47 -0700
Re: local variable Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-05 04:15 -0700
Re: local variable Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-05 04:27 -0700
Re: local variable Raimond Dragomir <raimond.dragomir@gmail.com> - 2015-07-05 04:39 -0700
Re: local variable franck.bensusan@gmail.com - 2015-07-05 07:08 -0700
csiph-web