Deutsch   English   Français   Italiano  
<vdp0tf$80bg$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Ruvim <ruvim.pinka@gmail.com>
Newsgroups: comp.lang.forth
Subject: Re: value-flavoured structures
Date: Fri, 4 Oct 2024 19:17:02 +0400
Organization: A noiseless patient Spider
Lines: 114
Message-ID: <vdp0tf$80bg$1@dont-email.me>
References: <nnd$61e0ad9a$48ed61c2@b4d945e456041481>
 <2024Sep13.200734@mips.complang.tuwien.ac.at> <66e4f98b$1@news.ausics.net>
 <2024Sep14.081952@mips.complang.tuwien.ac.at> <vc6t1b$27sna$1@dont-email.me>
 <2024Sep15.181634@mips.complang.tuwien.ac.at> <vd5pjl$kdp4$1@dont-email.me>
 <2024Oct3.175858@mips.complang.tuwien.ac.at> <vdo4q8$4h5p$1@dont-email.me>
 <2024Oct4.135221@mips.complang.tuwien.ac.at>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 04 Oct 2024 17:17:04 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="445a1e4b852452cb31a6977437e57eaf";
	logging-data="262512"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19y1oQTTPF/agXX3ZD6aSkj"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:UdzjMfIAAE/Rs38Ix++FBtPzLZ8=
In-Reply-To: <2024Oct4.135221@mips.complang.tuwien.ac.at>
Content-Language: en-US
Bytes: 4876

On 2024-10-04 15:52, Anton Ertl wrote:
> Ruvim <ruvim.pinka@gmail.com> writes:
>> 1. From the lexical point of view, "to foo" and "set-foo" are almost the
>> same.  "to foo" can even be considered a separate fancy word with a
>> space in its name.
> 
> Even closer: With the to-recognizer you can write ->FOO.
> 
>> 3. "set-foo" can be easily redefined (for example, if you want to check
>> the assigned value to prevent some bugs in advance).
>> "to foo" *cannot* be redefined. Although, one can redefine "to" to check
>> its argument and have a special action when its argument is "foo" — this
>> is very cumbersome.
> 
> Wrong.
> It can be defined: Gforth has SET-TO
> <https://gforth.org/manual/Words-with-user_002ddefined-TO-etc_002e.html>
> which allows you to define what TO FOO does.

Yes, I know ))
I wonder why a kind of "TO" is not used to set this field/property, and 
*maybe* a kind of "ACTION-OF" to get this property.


> If you mean that a standard program cannot define it, true,

Of course, I mean a standard program (and that is by default).
Otherwise my statement would be a denial of the obvious truth ;)


> but that's just a matter of what is currently standardized.

Yes, this is by default.



>> 4. "set-foo" can be accessed using qualified names, such as
>> mymodule::set-foo  or  mymodule( set-foo )
>> A variant like "to mymodule::foo" could work,

By "could work" I mean that this can potentially work in *any* system 
that have the corresponding capabilities (e.g., the Recognizers API).


>> a variant like "to mymodule( set-foo )" cannot work.

Typo: this should be read "to mymodule( foo )"


> 
> Let's see:
> 
> [~/gforth:152808] gforth
> Gforth 0.7.9_20241003
> Authors: Anton Ertl, Bernd Paysan, Jens Wilke et al., for more type `authors'
> Copyright © 2024 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
> Gforth comes with ABSOLUTELY NO WARRANTY; for details type `license'
> Type `help' for basic help
> vocabulary voc  ok
> also voc definitions  ok
> 5 value val  ok
> previous  ok
> voc:val  ok 1
> . 5  ok
> 7 to voc:val  \ <----------  ok
> also voc  ok
> val . 7  ok
> previous  ok
> 8 ->voc:val  \ <-----------  ok
> voc:val . 8  ok
> 3 +>voc:val  \ <-----------  ok
> voc:val . 11  ok

Behaves as expected!

> 
> I pointed out exactly where TO VOC:VAL, ->VOC:VAL and +>VOC:VAL occur.
> No not only can it work, it already works in Gforth.  And here the
> "standard program excuse" does not apply, because neither your
> qualification syntax nor Gforth's scope-recognizer are standardized.

Yes, that's right!




>> Bottom line: I don't see any advantages in *using* a to-based setter
>> over a separate setter.
> 
> However, lots of Forth programmers have defined VALUEs, and barely any
> have defined getters and setters.

Do you mean that this is due to some advantages in *using*?

I think, this is because `VALUE` (and co.) is a very old technique that 
is provided out of the box by many systems.  In contrast, to use 
separate getters and setters you need to create your own tool to define 
them.




> The discussions have been aboyt
> values vs. variables, not about values vs. getters and setters.

This shows that some people don't like the to-based approach.

I seen that some implementers provide "value" and "to" only for third 
party programs and don't use them themselves.


--
Ruvim