Path: csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Rod Pemberton" Newsgroups: comp.lang.forth Subject: Re: Which scripting for embedded automation? Date: Sun, 26 Jul 2015 21:26:54 -0400 Organization: Aioe.org NNTP Server Lines: 65 Message-ID: References: <0e930740-22d8-4e2b-833f-bb5843437d0d@googlegroups.com> <87y4i6rvyc.fsf@jester.gateway.sonic.net> <87lhe5sciz.fsf@jester.gateway.sonic.net> <8f8f8dd6-efca-4f3e-ac18-ed28bce7524c@googlegroups.com> NNTP-Posting-Host: n4wpt9zq8xR26Ttf9mo2BA.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Opera Mail/12.16 (Linux) X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.forth:40813 On Sun, 26 Jul 2015 21:07:21 -0400, Elizabeth D. Rather wrote: > On 7/26/15 11:11 AM, Rod Pemberton wrote: >> On Sun, 26 Jul 2015 13:53:14 -0400, Alex McDonald wrote: >>> on 26/07/2015 12:01:26, glidedog wrote: >>>> Mark's lament is understandable. Forth doesn't even have a built-in >>>> cell-sized-element array wordset. >>> >>> The definition of a 1 dimensional array is trivial; perhaps that's why. >>> >>> : 1dim create cells allot does> swap cells + ; >>> >>> 10 1dim myarray >>> 10 0 myarray ! >>> 20 1 myarray ! >>> 0 myarray @ 1 myarray @ + . >>> >> >> Okay, don't blow a fuse for me butting in without reading most of this, >> but ... >> >> How is that on factoring? >> >> Shouldn't there be a separate word to do array indexing so the indexing >> functionality can be re-used? Then, it would be factored, correct? ... >> >> E.g., >> >> : [] swap cells + ; >> : 1dim create cells allot ; >> >> 10 1dim myarray >> 10 0 myarray [] ! >> 20 1 myarray [] ! >> 0 myarray [] @ 1 myarray [] @ + . > > That is, in fact, very poor factoring, because it makes an extra > definition that you don't need. As Alex points out, multiple arrays > defined by 1dim will all share the same indexing code, so factoring that > out introduces an extra call. If the "extra" call is such an issue, what is wrong with this? : [] swap cells + ; : 1dim create cells allot does> [] ; 10 1dim myarray 10 0 myarray ! 20 1 myarray ! 0 myarray @ 1 myarray @ + . That preserves the functionality as a separate word and re-uses the same code in the does> . BTW, I see the "extra" call as being no different that the use of ! or @ above. I.e., they're extraneous too and can be hidden within long, non-factored definitions. Rod Pemberton -- Scientists now say we'll experience a mini-ice in 2030. So, I guess we need more global warming today ...