Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Forth > Re: & in A rati...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 7 Topic 4047 of 4053
Post > Topic >>

Re: & in A rationale for ARRAYs in the Forth Scientific Library

by "C. G. Montgomery" <cgm@[EMAIL PROTECTED] > May 10, 2008 at 01:11 PM

Josh Grams josh@[EMAIL PROTECTED]
 wrote:

> C. G. Montgomery <cgm@[EMAIL PROTECTED]
> wrote:
>> Michael michael.kalus@[EMAIL PROTECTED]
 wrote:
>>
>>> Is & a forth word? How about &! ?
>>
>> The words & and &! are among those defined in the fsl-util files in the
>> Auxiliary code provided with the Library:
>> http://www.taygeta.com/fsl/scilib.html
>>
>> Unfortunately, these and a number of other FSL words are defined only
>> by a particular implementation rather than fully specified, so other
>> implementations may provide the same functionality differently.  In
>> other words, full phrases such as the ones you quote, have standard
>> effects, while the individual words may behave differently.
> 
> Bleh.  That's not very helpful.  How about putting it this way?
> 
>   name{ ( -- elements )
>   & ( "array-name" -- array )
> 
It could be that  name{  returns not the address of the array data but
rather the address of related information (type, number of elements,
etc.).  That information would be used by  }  so that  name{ i }  does
indeed return the address of the ith element of the array, as it must.

&  in the original implementation produces an execution token, but could
be a noop.

I believe such implementations exist and work correctly.

> An `elements` reference is sufficient to access the elements of the
> array, but words which modify the array's structure need a full array
> reference.  You can only get an array reference for dynamically
> allocated arrays, as the structure of a statically allocated array can't
> be modified.
> 
>   &! ( elements array -- )  \ set ARRAY so that it refers to ELEMENTS
>   }malloc ( array u -- )    \ allocate U elements for ARRAY
>   }free ( array -- )        \ free the elements of ARRAY
> 
> Or does this abstraction break down in some cases?
> 
> --Josh

The essential point is that the Algorithms in the FSL always use the
array-related words in phrases which have well-defined effects.  There
are two different positions which be taken.  The first is that each word
of those phrases should behave exactly as in the original implementation. 
The second is that any implementation need only reproduce the behavior of
the full phrases, not necessarily of each individual word.  My own
personal preference is for the second position, since it allows more
freedom to developers without reducing the usefulness of the algorithms
themselves.  (I can say that I know of no case where the reviewing
process for the FSL encountered problems related to the choice between
these positions.)

But of course anyone could make any change he pleases to the fsl-util
words and then modify the Algorithms so that they behave correctly, so
the issue is more philosophical than pragmatic.  And Forth allows free
choice when it comes to Philosophy vs. Pragmatism.  ;-)

regards   cgm




 7 Posts in Topic:
& in A rationale for ARRAYs in the Forth Scientific Library
Michael <michael.kalus  2008-05-09 11:57:42 
Re: & in A rationale for ARRAYs in the Forth Scientific Library
"C. G. Montgomery&qu  2008-05-09 19:51:18 
Re: & in A rationale for ARRAYs in the Forth Scientific Library
Josh Grams <josh@[EMAI  2008-05-10 11:14:54 
Re: & in A rationale for ARRAYs in the Forth Scientific Library
"C. G. Montgomery&qu  2008-05-10 13:11:25 
Re: & in A rationale for ARRAYs in the Forth Scientific Library
Josh Grams <josh@[EMAI  2008-05-11 12:07:22 
Re: & in A rationale for ARRAYs in the Forth Scientific Library
Michael <michael.kalus  2008-05-11 00:48:42 
Re: & in A rationale for ARRAYs in the Forth Scientific Library
Bruce McFarling <agila  2008-05-11 11:07:41 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri May 16 1:26:05 CDT 2008.