Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #50412
| From | Bernd Paysan <bernd.paysan@gmx.de> |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: CfV: Quotations |
| Date | 2016-08-22 23:19 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <npg1ao$29b$1@dont-email.me> (permalink) |
| References | (4 earlier) <2016Aug16.091357@mips.complang.tuwien.ac.at> <npafji$59r$1@dont-email.me> <2016Aug21.113258@mips.complang.tuwien.ac.at> <npdbbl$vqt$2@dont-email.me> <2016Aug22.155432@mips.complang.tuwien.ac.at> |
Am Mon, 22 Aug 2016 13:54:32 +0000 schrieb Anton Ertl:
> The question is how often that helps for real-world programs. My guess
> is that, with the Pascal-like restriction, not often enough to make it
> worthwhile. With garbage-collection of closures, it would probably be
> worthwhile, but we probably don't want to go there; and for something in
> between, we will have to see.
MINOS uses a lot of closure-like objects+quotations, the "actions". An
action is bound to a widget, contains a state variable of its own (e.g.
on/off for a toggle button), and an action (or two), stored as quotation
xt; the quotation is performed in the context of the object that created
those actions and widgets. Since all that commons stuff is reused again
and again, it's just a slightly different version of [: ;] around a block
of code to instantiate them. So the line count is probably not a problem.
In Common Lisp, you would do that with closures. In an OOP system, you
do it with OOP. And if you want a more compact format of declaring
things, just define them. You could have an OOP system that declares the
class in one line, and creates you an instantiation code that takes the
initial values from stack, just with about the same amount of code we
need to implement locals (a lot more code than mini-oof2.fs).
<base class> O{ k x1 x2 x3 x4 x5 }O mob
certainly is possible. There's even a mini-oof.fs based implementation
of closures, which does just that. If we wanted to generalize the locals
declaration, we could easily reuse most of the code in glocals.fs; after
all, the declaration of a set of locals and the declaration of a set of
instance variables is the same problem: Create a bunch of names which
address consecutive elements in memory; one time on a locals stack,
another time in an object. And Algol 60 even recognizes that by calling
the locals "activation record".
If you look at the Rosetta code page of the man-or-boy test, you'll find
a number of implementations which use classes to implement the activation
record, so I think that approach is fair and useful.
http://rosettacode.org/wiki/Man_or_boy_test
If you want a class creation syntax which reduces line count, it's also
doable. mini-oof2.fs just shares code with the structure declaration,
sharing code with the locals declaration would also be possible.
--
Bernd Paysan
"If you want it done right, you have to do it yourself"
net2o ID: kQusJzA;7*?t=uy@X}1GWr!+0qqp_Cn176t4(dQ*
http://bernd-paysan.de/
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