Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #55741 > unrolled thread
| Started by | "HAA" <someone@microsoft.com> |
|---|---|
| First post | 2017-03-14 11:15 +1100 |
| Last post | 2017-04-12 08:13 +0200 |
| Articles | 20 on this page of 34 — 12 participants |
Back to article view | Back to comp.lang.forth
When to use !name vs. name! ? "HAA" <someone@microsoft.com> - 2017-03-14 11:15 +1100
Re: When to use !name vs. name! ? hughaguilar96@gmail.com - 2017-03-13 18:27 -0700
Re: When to use !name vs. name! ? Mark Wills <markwills1970@gmail.com> - 2017-03-14 01:33 -0700
Re: When to use !name vs. name! ? Mark Wills <markwills1970@gmail.com> - 2017-03-14 01:30 -0700
When to use !name vs. name! ? NN <november.nihal@gmail.com> - 2017-03-14 02:56 -0700
Re: When to use !name vs. name! ? "HAA" <someone@microsoft.com> - 2017-03-16 08:59 +1100
Re: When to use !name vs. name! ? Mark Wills <markwills1970@gmail.com> - 2017-03-16 02:11 -0700
Re: When to use !name vs. name! ? "HAA" <someone@microsoft.com> - 2017-03-17 11:19 +1100
Re: When to use !name vs. name! ? rickman <gnuarm@gmail.com> - 2017-03-16 20:46 -0400
Re: When to use !name vs. name! ? "Elizabeth D. Rather" <erather@forth.com> - 2017-03-16 21:34 -1000
Re: When to use !name vs. name! ? "HAA" <someone@microsoft.com> - 2017-03-18 09:49 +1100
Re: When to use !name vs. name! ? "Elizabeth D. Rather" <erather@forth.com> - 2017-03-17 13:08 -1000
Re: When to use !name vs. name! ? rickman <gnuarm@gmail.com> - 2017-03-17 19:35 -0400
Re: When to use !name vs. name! ? Mark Wills <markwills1970@gmail.com> - 2017-03-18 00:51 -0700
Re: When to use !name vs. name! ? "HAA" <someone@microsoft.com> - 2017-03-19 10:47 +1100
Re: When to use !name vs. name! ? rickman <gnuarm@gmail.com> - 2017-03-18 22:18 -0400
Re: When to use !name vs. name! ? "Elizabeth D. Rather" <erather@forth.com> - 2017-03-18 16:36 -1000
Re: When to use !name vs. name! ? rickman <gnuarm@gmail.com> - 2017-03-18 23:53 -0400
Re: When to use !name vs. name! ? "Elizabeth D. Rather" <erather@forth.com> - 2017-03-18 22:22 -1000
Re: When to use !name vs. name! ? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-03-19 16:03 +0000
Re: When to use !name vs. name! ? Alex <alex@rivadpm.com> - 2017-03-19 17:42 +0000
Re: When to use !name vs. name! ? "Elizabeth D. Rather" <erather@forth.com> - 2017-03-19 13:10 -1000
Re: When to use !name vs. name! ? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-03-19 13:34 +0100
Re: When to use !name vs. name! ? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2017-03-19 16:23 +0000
Re: When to use !name vs. name! ? albert@cherry.spenarnc.xs4all.nl (Albert van der Horst) - 2017-03-19 20:47 +0100
Re: When to use !name vs. name! ? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2017-03-20 03:47 -0500
Re: When to use !name vs. name! ? "HAA" <someone@microsoft.com> - 2017-03-20 09:41 +1100
Re: When to use !name vs. name! ? Coos Haak <htrofhc@gmail.com> - 2017-03-20 01:24 +0100
Re: When to use !name vs. name! ? "HAA" <someone@microsoft.com> - 2017-03-21 12:10 +1100
Re: When to use !name vs. name! ? hughaguilar96@gmail.com - 2017-03-20 18:45 -0700
Re: When to use !name vs. name! ? Coos Haak <htrofhc@gmail.com> - 2017-03-21 14:58 +0100
Re: When to use !name vs. name! ? "HAA" <someone@microsoft.com> - 2017-03-22 19:49 +1100
Re: When to use !name vs. name! ? hughaguilar96@gmail.com - 2017-03-17 16:46 -0700
Re: When to use !name vs. name! ? Lars Brinkhoff <lars.spam@nocrew.org> - 2017-04-12 08:13 +0200
Page 1 of 2 [1] 2 Next page →
| From | "HAA" <someone@microsoft.com> |
|---|---|
| Date | 2017-03-14 11:15 +1100 |
| Subject | When to use !name vs. name! ? |
| Message-ID | <oa7clo$1pao$1@gioia.aioe.org> |
This has come up before but without resolution i.e. when to use the form !name @name vs. name! name@ ? The advantage of these is shortness. Thinking Forth and FHP list both forms but the descriptions are too vague or in some cases identical. Scanning SwiftForth source files hasn't helped as there aren't enough examples to suggest a pattern. One rationale is to use !xxx @xxx when the operation doesn't take or leave items on the data stack e.g. @settings ( -- ) !settings ( -- ) This is fine but such cases don't occur often enough to warrant the use.
[toc] | [next] | [standalone]
| From | hughaguilar96@gmail.com |
|---|---|
| Date | 2017-03-13 18:27 -0700 |
| Message-ID | <7b02f43e-0a54-4ea6-a143-9185dd9a5883@googlegroups.com> |
| In reply to | #55741 |
On Monday, March 13, 2017 at 5:14:53 PM UTC-7, HAA wrote: > This has come up before but without resolution i.e. when to use the form > !name @name vs. name! name@ ? > > The advantage of these is shortness. Thinking Forth and FHP list both > forms but the descriptions are too vague or in some cases identical. > Scanning SwiftForth source files hasn't helped as there aren't enough > examples to suggest a pattern. > > One rationale is to use !xxx @xxx when the operation doesn't take or > leave items on the data stack e.g. > @settings ( -- ) !settings ( -- ) > > This is fine but such cases don't occur often enough to warrant the use. I would use NAME@ and NAME! --- but it is not a big deal either way. For example, ANS-Forth should have provided STATE@ rather than provide STATE and then give us this rule: "Note: A program shall not directly alter the contents of STATE." How does an ANS-Forth system prevent somebody from storing into the address that STATE provided?
[toc] | [prev] | [next] | [standalone]
| From | Mark Wills <markwills1970@gmail.com> |
|---|---|
| Date | 2017-03-14 01:33 -0700 |
| Message-ID | <2d292917-e6a5-4d75-8b95-9eaf6a34bdc0@googlegroups.com> |
| In reply to | #55743 |
On Tuesday, 14 March 2017 01:27:14 UTC, hughag...@gmail.com wrote: > On Monday, March 13, 2017 at 5:14:53 PM UTC-7, HAA wrote: > > This has come up before but without resolution i.e. when to use the form > > !name @name vs. name! name@ ? > > > > The advantage of these is shortness. Thinking Forth and FHP list both > > forms but the descriptions are too vague or in some cases identical. > > Scanning SwiftForth source files hasn't helped as there aren't enough > > examples to suggest a pattern. > > > > One rationale is to use !xxx @xxx when the operation doesn't take or > > leave items on the data stack e.g. > > @settings ( -- ) !settings ( -- ) > > > > This is fine but such cases don't occur often enough to warrant the use. > > I would use NAME@ and NAME! --- but it is not a big deal either way. > For words that accept/return arguments, yes. For words that don't I like HAA's suggestion, above, with perhaps one small modification: I'd use it for words that don't have inputs, but do have outputs: @screenResolution ( -- width height ) ...for example.
[toc] | [prev] | [next] | [standalone]
| From | Mark Wills <markwills1970@gmail.com> |
|---|---|
| Date | 2017-03-14 01:30 -0700 |
| Message-ID | <d6ddea64-43ae-4bfd-8619-0d72a730da3b@googlegroups.com> |
| In reply to | #55741 |
On Tuesday, 14 March 2017 00:14:53 UTC, HAA wrote: > > One rationale is to use !xxx @xxx when the operation doesn't take or > leave items on the data stack e.g. > @settings ( -- ) !settings ( -- ) > > This is fine but such cases don't occur often enough to warrant the use. Never really thought about it, but your rationale above sounds perfectly good to me. I'll try to use it in that way in the future.
[toc] | [prev] | [next] | [standalone]
| From | NN <november.nihal@gmail.com> |
|---|---|
| Date | 2017-03-14 02:56 -0700 |
| Message-ID | <c7253573-ae6f-4817-87d2-d252e12fdb84@googlegroups.com> |
| In reply to | #55741 |
Assuming name is a variable. I would use !name to change the value in name. I would use name! to change the value pointed to by the value stored in name. If name was a register then you can see how that extends. NN
[toc] | [prev] | [next] | [standalone]
| From | "HAA" <someone@microsoft.com> |
|---|---|
| Date | 2017-03-16 08:59 +1100 |
| Message-ID | <oacdb8$1ckm$1@gioia.aioe.org> |
| In reply to | #55757 |
NN wrote: > Assuming name is a variable. > I would use !name to change the value in name. > I would use name! to change the value pointed to by the value stored in name. > > If name was a register then you can see how that extends. > > NN Staying with the idea of rules for the different forms: Where name is a variable (of any datatype), then name@ name! can be short-forms for name <fetch> and name <store>. Many functions end up with GET or SET as a prefix to the name. This can get clunky quickly, so using @name and !name for those may be a better alternative.
[toc] | [prev] | [next] | [standalone]
| From | Mark Wills <markwills1970@gmail.com> |
|---|---|
| Date | 2017-03-16 02:11 -0700 |
| Message-ID | <9082c24f-cba7-4b02-9413-60c8610ef9fe@googlegroups.com> |
| In reply to | #55829 |
On Wednesday, 15 March 2017 21:57:01 UTC, HAA wrote: > NN wrote: > > Assuming name is a variable. > > I would use !name to change the value in name. > > I would use name! to change the value pointed to by the value stored in name. > > > > If name was a register then you can see how that extends. > > > > NN > > Staying with the idea of rules for the different forms: > > Where name is a variable (of any datatype), then name@ name! > can be short-forms for name <fetch> and name <store>. > > Many functions end up with GET or SET as a prefix to the name. > This can get clunky quickly, so using @name and !name for > those may be a better alternative. This going off on a tangent somewhat, but you might find this interesting: http://turboforth.net/resources/fastvars.html Regards Mark
[toc] | [prev] | [next] | [standalone]
| From | "HAA" <someone@microsoft.com> |
|---|---|
| Date | 2017-03-17 11:19 +1100 |
| Message-ID | <oaf9v0$2e6$1@gioia.aioe.org> |
| In reply to | #55843 |
Mark Wills wrote: > On Wednesday, 15 March 2017 21:57:01 UTC, HAA wrote: > > NN wrote: > > > Assuming name is a variable. > > > I would use !name to change the value in name. > > > I would use name! to change the value pointed to by the value stored in name. > > > > > > If name was a register then you can see how that extends. > > > > > > NN > > > > Staying with the idea of rules for the different forms: > > > > Where name is a variable (of any datatype), then name@ name! > > can be short-forms for name <fetch> and name <store>. > > > > Many functions end up with GET or SET as a prefix to the name. > > This can get clunky quickly, so using @name and !name for > > those may be a better alternative. > > This going off on a tangent somewhat, but you might find this interesting: > > http://turboforth.net/resources/fastvars.html > > Regards > > Mark Interesting! Has the advantage of not having to remember whether 'name' was a VARIABLE or a VALUE.
[toc] | [prev] | [next] | [standalone]
| From | rickman <gnuarm@gmail.com> |
|---|---|
| Date | 2017-03-16 20:46 -0400 |
| Subject | Re: When to use !name vs. name! ? |
| Message-ID | <oafbg5$o8g$1@dont-email.me> |
| In reply to | #55741 |
On 3/13/2017 8:15 PM, HAA wrote: > This has come up before but without resolution i.e. when to use the form > !name @name vs. name! name@ ? > > The advantage of these is shortness. Thinking Forth and FHP list both > forms but the descriptions are too vague or in some cases identical. > Scanning SwiftForth source files hasn't helped as there aren't enough > examples to suggest a pattern. > > One rationale is to use !xxx @xxx when the operation doesn't take or > leave items on the data stack e.g. > @settings ( -- ) !settings ( -- ) > > This is fine but such cases don't occur often enough to warrant the use. I guess I'm showing my lack of experience, but when do fetch and store words not use parameters on the stack? I thought there was already a convention that words which are functionally equivalent to name @ and name ! would be name@ and name! respectively. No? What would you need @name for? -- Rick C
[toc] | [prev] | [next] | [standalone]
| From | "Elizabeth D. Rather" <erather@forth.com> |
|---|---|
| Date | 2017-03-16 21:34 -1000 |
| Subject | Re: When to use !name vs. name! ? |
| Message-ID | <rr6dnZECzYMUDFbFnZ2dnUU7-dnNnZ2d@supernews.com> |
| In reply to | #55860 |
On 3/16/17 2:46 PM, rickman wrote: > On 3/13/2017 8:15 PM, HAA wrote: >> This has come up before but without resolution i.e. when to use the form >> !name @name vs. name! name@ ? >> >> The advantage of these is shortness. Thinking Forth and FHP list both >> forms but the descriptions are too vague or in some cases identical. >> Scanning SwiftForth source files hasn't helped as there aren't enough >> examples to suggest a pattern. >> >> One rationale is to use !xxx @xxx when the operation doesn't take or >> leave items on the data stack e.g. >> @settings ( -- ) !settings ( -- ) >> >> This is fine but such cases don't occur often enough to warrant the use. > > I guess I'm showing my lack of experience, but when do fetch and store > words not use parameters on the stack? > > I thought there was already a convention that words which are > functionally equivalent to name @ and name ! would be name@ and name! > respectively. No? > > What would you need @name for? That's a carryover from the very early days, when Forth names were stored in the dictionary as count+1st 3 chars. In the era of extreme memory conservation (mostly the 70's; at NRAO Chuck controlled the 36' radio telescope and its dome and managed 4 concurrent terminals with operators in a 32Kb computer) that was necessary. So, we put the operant symbol (@ or !) first. Cheers. Elizabeth -- Elizabeth R. Conklin FORTH, Inc. 6080 Center Drive, Suite 600 Los Angeles, CA 90045 USA
[toc] | [prev] | [next] | [standalone]
| From | "HAA" <someone@microsoft.com> |
|---|---|
| Date | 2017-03-18 09:49 +1100 |
| Subject | Re: When to use !name vs. name! ? |
| Message-ID | <oahp1s$341$1@gioia.aioe.org> |
| In reply to | #55862 |
Elizabeth D. Rather wrote: > On 3/16/17 2:46 PM, rickman wrote: > > On 3/13/2017 8:15 PM, HAA wrote: > >> This has come up before but without resolution i.e. when to use the form > >> !name @name vs. name! name@ ? > >> > >> The advantage of these is shortness. Thinking Forth and FHP list both > >> forms but the descriptions are too vague or in some cases identical. > >> Scanning SwiftForth source files hasn't helped as there aren't enough > >> examples to suggest a pattern. > >> > >> One rationale is to use !xxx @xxx when the operation doesn't take or > >> leave items on the data stack e.g. > >> @settings ( -- ) !settings ( -- ) > >> > >> This is fine but such cases don't occur often enough to warrant the use. > > > > I guess I'm showing my lack of experience, but when do fetch and store > > words not use parameters on the stack? > > > > I thought there was already a convention that words which are > > functionally equivalent to name @ and name ! would be name@ and name! > > respectively. No? > > > > What would you need @name for? > > That's a carryover from the very early days, when Forth names were > stored in the dictionary as count+1st 3 chars. In the era of extreme > memory conservation (mostly the 70's; at NRAO Chuck controlled the 36' > radio telescope and its dome and managed 4 concurrent terminals with > operators in a 32Kb computer) that was necessary. So, we put the operant > symbol (@ or !) first. > > Cheers. > Elizabeth Never considered that. Would you then regard it as an obsolete convention best forgotten - or would it have some (new) use today?
[toc] | [prev] | [next] | [standalone]
| From | "Elizabeth D. Rather" <erather@forth.com> |
|---|---|
| Date | 2017-03-17 13:08 -1000 |
| Subject | Re: When to use !name vs. name! ? |
| Message-ID | <vJidnaF6x-728VHFnZ2dnUU7-KvNnZ2d@supernews.com> |
| In reply to | #55877 |
On 3/17/17 12:49 PM, HAA wrote: > Elizabeth D. Rather wrote: >> On 3/16/17 2:46 PM, rickman wrote: >>> On 3/13/2017 8:15 PM, HAA wrote: >>>> This has come up before but without resolution i.e. when to use the form >>>> !name @name vs. name! name@ ? >>>> >>>> The advantage of these is shortness. Thinking Forth and FHP list both >>>> forms but the descriptions are too vague or in some cases identical. >>>> Scanning SwiftForth source files hasn't helped as there aren't enough >>>> examples to suggest a pattern. >>>> >>>> One rationale is to use !xxx @xxx when the operation doesn't take or >>>> leave items on the data stack e.g. >>>> @settings ( -- ) !settings ( -- ) >>>> >>>> This is fine but such cases don't occur often enough to warrant the use. >>> >>> I guess I'm showing my lack of experience, but when do fetch and store >>> words not use parameters on the stack? >>> >>> I thought there was already a convention that words which are >>> functionally equivalent to name @ and name ! would be name@ and name! >>> respectively. No? >>> >>> What would you need @name for? >> >> That's a carryover from the very early days, when Forth names were >> stored in the dictionary as count+1st 3 chars. In the era of extreme >> memory conservation (mostly the 70's; at NRAO Chuck controlled the 36' >> radio telescope and its dome and managed 4 concurrent terminals with >> operators in a 32Kb computer) that was necessary. So, we put the operant >> symbol (@ or !) first. >> >> Cheers. >> Elizabeth > > Never considered that. Would you then regard it as an obsolete convention > best forgotten - or would it have some (new) use today? It depends on the word. Words that simply fetch a value from a variable aren't substantive enough to justify separates @/! definitions, so it really depends on what the rest of the action is. I can imagine an application that uses a thermocouple, for example. The name of the port that controls it is Thermo. I would have words like !Thermo to write to it and @Thermo to read it and maybe perform a calibration. I would prefer to have the symbol first in these cases because it's the action that's important, not the thing being acted upon. Cheers, Elizabeth -- Elizabeth R. Conklin FORTH, Inc. 6080 Center Drive, Suite 600 Los Angeles, CA 90045 USA
[toc] | [prev] | [next] | [standalone]
| From | rickman <gnuarm@gmail.com> |
|---|---|
| Date | 2017-03-17 19:35 -0400 |
| Subject | Re: When to use !name vs. name! ? |
| Message-ID | <oahrln$jg2$1@dont-email.me> |
| In reply to | #55878 |
On 3/17/2017 7:08 PM, Elizabeth D. Rather wrote: > On 3/17/17 12:49 PM, HAA wrote: >> Elizabeth D. Rather wrote: >>> On 3/16/17 2:46 PM, rickman wrote: >>>> On 3/13/2017 8:15 PM, HAA wrote: >>>>> This has come up before but without resolution i.e. when to use the >>>>> form >>>>> !name @name vs. name! name@ ? >>>>> >>>>> The advantage of these is shortness. Thinking Forth and FHP list both >>>>> forms but the descriptions are too vague or in some cases identical. >>>>> Scanning SwiftForth source files hasn't helped as there aren't enough >>>>> examples to suggest a pattern. >>>>> >>>>> One rationale is to use !xxx @xxx when the operation doesn't >>>>> take or >>>>> leave items on the data stack e.g. >>>>> @settings ( -- ) !settings ( -- ) >>>>> >>>>> This is fine but such cases don't occur often enough to warrant the >>>>> use. >>>> >>>> I guess I'm showing my lack of experience, but when do fetch and store >>>> words not use parameters on the stack? >>>> >>>> I thought there was already a convention that words which are >>>> functionally equivalent to name @ and name ! would be name@ and name! >>>> respectively. No? >>>> >>>> What would you need @name for? >>> >>> That's a carryover from the very early days, when Forth names were >>> stored in the dictionary as count+1st 3 chars. In the era of extreme >>> memory conservation (mostly the 70's; at NRAO Chuck controlled the 36' >>> radio telescope and its dome and managed 4 concurrent terminals with >>> operators in a 32Kb computer) that was necessary. So, we put the operant >>> symbol (@ or !) first. >>> >>> Cheers. >>> Elizabeth >> >> Never considered that. Would you then regard it as an obsolete >> convention >> best forgotten - or would it have some (new) use today? > > It depends on the word. Words that simply fetch a value from a variable > aren't substantive enough to justify separates @/! definitions, so it > really depends on what the rest of the action is. I can imagine an > application that uses a thermocouple, for example. The name of the port > that controls it is Thermo. I would have words like !Thermo to write to > it and @Thermo to read it and maybe perform a calibration. I would > prefer to have the symbol first in these cases because it's the action > that's important, not the thing being acted upon. So reverse the method used across Forth because the action is important? Is it really not important what it is acting on? I think it is the opposite. The noun should be first since that is the important part. The verb is last because it only has meaning in the context of what it is acting on. One concrete advantage of noun first is that an alphabetized listing of the words will group them by the noun rather than by the action. The uses I have seen for @name and !name are on the GA144 where they are indirect operators. Use the contents of register "name" as an address for the action. I don't see that being used a lot in regular Forth, but I suppose anytime you are working with pointers that might be useful. In fact, with the GA144 the instruction names get so terse as to leave out the "name" entirely. "@" specifically implies an indirect operation through the A register for example. Conversely fetching the contents of register A is just "a". Go figure! -- Rick C
[toc] | [prev] | [next] | [standalone]
| From | Mark Wills <markwills1970@gmail.com> |
|---|---|
| Date | 2017-03-18 00:51 -0700 |
| Subject | Re: When to use !name vs. name! ? |
| Message-ID | <eab3718f-9ec6-40d7-9f70-f9cc6ac9d5bf@googlegroups.com> |
| In reply to | #55881 |
On Friday, 17 March 2017 23:35:01 UTC, rickman wrote: > The uses I have seen for @name and !name are on the GA144 where they are > indirect operators. Use the contents of register "name" as an address > for the action. I don't see that being used a lot in regular Forth, but > I suppose anytime you are working with pointers that might be useful. > In fact, with the GA144 the instruction names get so terse as to leave > out the "name" entirely. "@" specifically implies an indirect operation > through the A register for example. Conversely fetching the contents of > register A is just "a". Go figure! > > -- > > Rick C For indirection, I think I'm more inclined to use an assembler type nomenclature: @(thing) "fetch from the address *referenced* by thing" Which I guess would be defined as: Thing is, Forth intrinsics are so concise that the code is actually clearer if you write: thing @ @ Now it's obvious what you're doing; to you in six months time, and to somebody else that may be having to modify your code!
[toc] | [prev] | [next] | [standalone]
| From | "HAA" <someone@microsoft.com> |
|---|---|
| Date | 2017-03-19 10:47 +1100 |
| Subject | Re: When to use !name vs. name! ? |
| Message-ID | <oakgpo$mjn$1@gioia.aioe.org> |
| In reply to | #55881 |
rickman wrote: > On 3/17/2017 7:08 PM, Elizabeth D. Rather wrote: > > ... > > It depends on the word. Words that simply fetch a value from a variable > > aren't substantive enough to justify separates @/! definitions, so it > > really depends on what the rest of the action is. I can imagine an > > application that uses a thermocouple, for example. The name of the port > > that controls it is Thermo. I would have words like !Thermo to write to > > it and @Thermo to read it and maybe perform a calibration. I would > > prefer to have the symbol first in these cases because it's the action > > that's important, not the thing being acted upon. > > So reverse the method used across Forth because the action is important? > Is it really not important what it is acting on? I think it is the > opposite. The noun should be first since that is the important part. > The verb is last because it only has meaning in the context of what it > is acting on. > ... There are numerous cases where the action comes first and the object the qualification e.g. open/close-file read/write-line get/set-order, begin/end-xxx. In this context @/!name becomes shortform for get/set restore/save etc. Where the action is trivial e.g. peek/poke memory then the object takes precedence and reflects the stack order. e.g. name@/! . Being a trivial operation however, there may be little need for defining a such a function.
[toc] | [prev] | [next] | [standalone]
| From | rickman <gnuarm@gmail.com> |
|---|---|
| Date | 2017-03-18 22:18 -0400 |
| Subject | Re: When to use !name vs. name! ? |
| Message-ID | <oakpjr$lf6$1@dont-email.me> |
| In reply to | #55910 |
On 3/18/2017 7:47 PM, HAA wrote: > rickman wrote: >> On 3/17/2017 7:08 PM, Elizabeth D. Rather wrote: >>> ... >>> It depends on the word. Words that simply fetch a value from a variable >>> aren't substantive enough to justify separates @/! definitions, so it >>> really depends on what the rest of the action is. I can imagine an >>> application that uses a thermocouple, for example. The name of the port >>> that controls it is Thermo. I would have words like !Thermo to write to >>> it and @Thermo to read it and maybe perform a calibration. I would >>> prefer to have the symbol first in these cases because it's the action >>> that's important, not the thing being acted upon. >> >> So reverse the method used across Forth because the action is important? >> Is it really not important what it is acting on? I think it is the >> opposite. The noun should be first since that is the important part. >> The verb is last because it only has meaning in the context of what it >> is acting on. >> ... > > There are numerous cases where the action comes first and the object the > qualification e.g. open/close-file read/write-line get/set-order, begin/end-xxx. > In this context @/!name becomes shortform for get/set restore/save etc. > Where the action is trivial e.g. peek/poke memory then the object takes > precedence and reflects the stack order. e.g. name@/! . Being a trivial > operation however, there may be little need for defining a such a function. But the fetch and store operations have an operator @ and !. Usage is <name> @ or <name> !. Combining these words into one operator the convention would be name@ or name!. I've seen this guideline explicitly stated for cases like 1+ or 2* and many others. -- Rick C
[toc] | [prev] | [next] | [standalone]
| From | "Elizabeth D. Rather" <erather@forth.com> |
|---|---|
| Date | 2017-03-18 16:36 -1000 |
| Subject | Re: When to use !name vs. name! ? |
| Message-ID | <bJmdndkW2_YCc1DFnZ2dnUU7-U_NnZ2d@supernews.com> |
| In reply to | #55916 |
On 3/18/17 4:18 PM, rickman wrote: > On 3/18/2017 7:47 PM, HAA wrote: >> rickman wrote: >>> On 3/17/2017 7:08 PM, Elizabeth D. Rather wrote: >>>> ... >>>> It depends on the word. Words that simply fetch a value from a variable >>>> aren't substantive enough to justify separates @/! definitions, so it >>>> really depends on what the rest of the action is. I can imagine an >>>> application that uses a thermocouple, for example. The name of the port >>>> that controls it is Thermo. I would have words like !Thermo to >>>> write to >>>> it and @Thermo to read it and maybe perform a calibration. I would >>>> prefer to have the symbol first in these cases because it's the action >>>> that's important, not the thing being acted upon. >>> >>> So reverse the method used across Forth because the action is important? >>> Is it really not important what it is acting on? I think it is the >>> opposite. The noun should be first since that is the important part. >>> The verb is last because it only has meaning in the context of what it >>> is acting on. >>> ... >> >> There are numerous cases where the action comes first and the object the >> qualification e.g. open/close-file read/write-line get/set-order, >> begin/end-xxx. >> In this context @/!name becomes shortform for get/set restore/save etc. >> Where the action is trivial e.g. peek/poke memory then the object takes >> precedence and reflects the stack order. e.g. name@/! . Being a trivial >> operation however, there may be little need for defining a such a >> function. > > But the fetch and store operations have an operator @ and !. Usage is > <name> @ or <name> !. Combining these words into one operator the > convention would be name@ or name!. I've seen this guideline explicitly > stated for cases like 1+ or 2* and many others. The trivial case, combining <name> @/! into one, is hardly worth doing. 1+ and 2*, on the other hand, are worth defining in code on ITC implementations because they can resolve to a single machine instruction, which is why they're in CORE. Cheers, Elizabeth -- Elizabeth R. Conklin FORTH, Inc. 6080 Center Drive, Suite 600 Los Angeles, CA 90045 USA
[toc] | [prev] | [next] | [standalone]
| From | rickman <gnuarm@gmail.com> |
|---|---|
| Date | 2017-03-18 23:53 -0400 |
| Subject | Re: When to use !name vs. name! ? |
| Message-ID | <oakv5o$qc1$2@dont-email.me> |
| In reply to | #55917 |
On 3/18/2017 10:36 PM, Elizabeth D. Rather wrote: > On 3/18/17 4:18 PM, rickman wrote: >> On 3/18/2017 7:47 PM, HAA wrote: >>> rickman wrote: >>>> On 3/17/2017 7:08 PM, Elizabeth D. Rather wrote: >>>>> ... >>>>> It depends on the word. Words that simply fetch a value from a >>>>> variable >>>>> aren't substantive enough to justify separates @/! definitions, so it >>>>> really depends on what the rest of the action is. I can imagine an >>>>> application that uses a thermocouple, for example. The name of the >>>>> port >>>>> that controls it is Thermo. I would have words like !Thermo to >>>>> write to >>>>> it and @Thermo to read it and maybe perform a calibration. I would >>>>> prefer to have the symbol first in these cases because it's the action >>>>> that's important, not the thing being acted upon. >>>> >>>> So reverse the method used across Forth because the action is >>>> important? >>>> Is it really not important what it is acting on? I think it is the >>>> opposite. The noun should be first since that is the important part. >>>> The verb is last because it only has meaning in the context of what it >>>> is acting on. >>>> ... >>> >>> There are numerous cases where the action comes first and the object the >>> qualification e.g. open/close-file read/write-line get/set-order, >>> begin/end-xxx. >>> In this context @/!name becomes shortform for get/set restore/save >>> etc. >>> Where the action is trivial e.g. peek/poke memory then the object takes >>> precedence and reflects the stack order. e.g. name@/! . Being a trivial >>> operation however, there may be little need for defining a such a >>> function. >> >> But the fetch and store operations have an operator @ and !. Usage is >> <name> @ or <name> !. Combining these words into one operator the >> convention would be name@ or name!. I've seen this guideline explicitly >> stated for cases like 1+ or 2* and many others. > > The trivial case, combining <name> @/! into one, is hardly worth doing. > 1+ and 2*, on the other hand, are worth defining in code on ITC > implementations because they can resolve to a single machine > instruction, which is why they're in CORE. I think that depends entirely on what is required to perform the read or write. Some registers have a protocol. So if you are condensing a number of operations into one it can be worth defining a word. -- Rick C
[toc] | [prev] | [next] | [standalone]
| From | "Elizabeth D. Rather" <erather@forth.com> |
|---|---|
| Date | 2017-03-18 22:22 -1000 |
| Subject | Re: When to use !name vs. name! ? |
| Message-ID | <L_6dnTsdnMh9olPFnZ2dnUU7-QXNnZ2d@supernews.com> |
| In reply to | #55918 |
On 3/18/17 5:53 PM, rickman wrote: > On 3/18/2017 10:36 PM, Elizabeth D. Rather wrote: >> On 3/18/17 4:18 PM, rickman wrote: >>> On 3/18/2017 7:47 PM, HAA wrote: >>>> rickman wrote: >>>>> On 3/17/2017 7:08 PM, Elizabeth D. Rather wrote: >>>>>> ... >>>>>> It depends on the word. Words that simply fetch a value from a >>>>>> variable >>>>>> aren't substantive enough to justify separates @/! definitions, so it >>>>>> really depends on what the rest of the action is. I can imagine an >>>>>> application that uses a thermocouple, for example. The name of the >>>>>> port >>>>>> that controls it is Thermo. I would have words like !Thermo to >>>>>> write to >>>>>> it and @Thermo to read it and maybe perform a calibration. I would >>>>>> prefer to have the symbol first in these cases because it's the >>>>>> action >>>>>> that's important, not the thing being acted upon. >>>>> >>>>> So reverse the method used across Forth because the action is >>>>> important? >>>>> Is it really not important what it is acting on? I think it is the >>>>> opposite. The noun should be first since that is the important part. >>>>> The verb is last because it only has meaning in the context of what it >>>>> is acting on. >>>>> ... >>>> >>>> There are numerous cases where the action comes first and the object >>>> the >>>> qualification e.g. open/close-file read/write-line get/set-order, >>>> begin/end-xxx. >>>> In this context @/!name becomes shortform for get/set restore/save >>>> etc. >>>> Where the action is trivial e.g. peek/poke memory then the object takes >>>> precedence and reflects the stack order. e.g. name@/! . Being a >>>> trivial >>>> operation however, there may be little need for defining a such a >>>> function. >>> >>> But the fetch and store operations have an operator @ and !. Usage is >>> <name> @ or <name> !. Combining these words into one operator the >>> convention would be name@ or name!. I've seen this guideline explicitly >>> stated for cases like 1+ or 2* and many others. >> >> The trivial case, combining <name> @/! into one, is hardly worth doing. >> 1+ and 2*, on the other hand, are worth defining in code on ITC >> implementations because they can resolve to a single machine >> instruction, which is why they're in CORE. > > I think that depends entirely on what is required to perform the read or > write. Some registers have a protocol. So if you are condensing a > number of operations into one it can be worth defining a word. In most ITC Forths, the stack pointer is in a register, and an increment or shift is one instruction (possibly indirect). There is no read or write. I don't remember any instruction sets in which it is not possible to increment or shift left the TOS in one instruction. A C implementation, of course, may be much less efficient. Cheers, Elizabeth -- Elizabeth R. Conklin FORTH, Inc. 6080 Center Drive, Suite 600 Los Angeles, CA 90045 USA
[toc] | [prev] | [next] | [standalone]
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Date | 2017-03-19 16:03 +0000 |
| Subject | Re: When to use !name vs. name! ? |
| Message-ID | <2017Mar19.170308@mips.complang.tuwien.ac.at> |
| In reply to | #55920 |
"Elizabeth D. Rather" <erather@forth.com> writes:
>On 3/18/17 5:53 PM, rickman wrote:
>> On 3/18/2017 10:36 PM, Elizabeth D. Rather wrote:
>>> On 3/18/17 4:18 PM, rickman wrote:
>>>> But the fetch and store operations have an operator @ and !. Usage is
>>>> <name> @ or <name> !. Combining these words into one operator the
>>>> convention would be name@ or name!. I've seen this guideline explicitly
>>>> stated for cases like 1+ or 2* and many others.
>>>
>>> The trivial case, combining <name> @/! into one, is hardly worth doing.
>>> 1+ and 2*, on the other hand, are worth defining in code on ITC
>>> implementations because they can resolve to a single machine
>>> instruction, which is why they're in CORE.
>>
>> I think that depends entirely on what is required to perform the read or
>> write. Some registers have a protocol. So if you are condensing a
>> number of operations into one it can be worth defining a word.
Sure, if you do an access to an 8086 port or something, you could call
the reading word BLA@ and the writing word BLA!.
>In most ITC Forths, the stack pointer is in a register, and an increment
>or shift is one instruction (possibly indirect). There is no read or
>write. I don't remember any instruction sets in which it is not possible
>to increment or shift left the TOS in one instruction. A C
>implementation, of course, may be much less efficient.
Just to illustrate this, here's what you get in gforth-fast:
: foo 1+ 2* ; ok
: bar 1 + 2 * ; ok
see-code foo
$7F2CA4B88390 1+
7F2CA4AF6505: add rbx,$08 \ update ip (of threaded code)
7F2CA4AF6509: add r14,$01 \ tos = tos + 1
$7F2CA4B88398 2*
7F2CA4AF650D: add rbx,$08 \ update ip (of threaded code)
7F2CA4AF6511: add r14,r14 \ tos = tos + tos
$7F2CA4B883A0 ;s
see-code bar
$7F2CA4B883E0 lit
$7F2CA4B883E8 <$1>
$7F2CA4B883F0 <$0> \ actually +, but combined with LIT
7F2CA4AF6529: add r14,[rbx] \ tos = tos + *ip
7F2CA4AF652C: add rbx,$18 \ update ip (of threaded code)
$7F2CA4B883F8 noop \ actually LIT, decompiler acting up
$7F2CA4B88400 <$2>
7F2CA4AF6530: mov [r15],r14
7F2CA4AF6533: sub r15,$08
7F2CA4AF6537: mov rax,rbx
7F2CA4AF653A: lea rbx,$10[rbx]
7F2CA4AF653E: mov r14,[rax]
$7F2CA4B88408 *
7F2CA4AF6541: mov rax,r15
7F2CA4AF6544: lea r15,$08[r15]
7F2CA4AF6548: add rbx,$08
7F2CA4AF654C: imul r14,$08[rax]
$7F2CA4B88410 ;s ok
In the BAR example you see that Gforth-fast has a static
superinstruction for "lit <num> +", but none for "lit <num> *". So
for the "2 *" you see all the stack access overhead. You don't see
threaded-code overhead apart from the ip updates thanks to dynamic
superinstructions. And it looks like we are now using Intel assembler
syntax in the disassembler.
- 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/
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | comp.lang.forth
csiph-web