Basic Coding question, I do not recall seeing addressed in the literature

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Basic Coding question, I do not recall seeing addressed in the literature

Squeak - Dev mailing list
Hi Folks,

Pardon the noobish "eyes of wonder" on the following. 

Recently, Eliot asked...
   what is the value of
      { (Float infinity basicAt: 1) hex.
        (Float infinity basicAt: 2) hex.
        (BoxedFloat64 infinity basicAt: 1) hex.
        (BoxedFloat64 infinity basicAt: 2) hex.
         BoxedFloat64 infinity == Float infinity }

The result is:


#('16r7FF00000' '16r0' '16r7FF00000' '16r0' true)
This shows that the stuff in an Array is evaluated BEFORE the array is "produced".

This is NOT in the Terse Guide and I do not recall seeing it in the books I read when I first started Squeak.

It is a very handy tool.

I guess the behavior makes sense, as an Array is not a Block . Also, putting the same stuff in an OrderedCollection gives the same behavior.


|x|
x := OrderedCollection new.
x add:(Float infinity basicAt: 1) hex.
x add:(Float infinity basicAt: 2) hex.
x add:(BoxedFloat64 infinity basicAt: 1) hex.
x add:(BoxedFloat64 infinity basicAt: 2) hex.
x add: BoxedFloat64 infinity == Float infinity .
x inspect.


The construct is very reminiscent of on of the early lessons in the SICP series, 


Anyhoo, one more cool thing to add to the toolbox.

cheers.



Reply | Threaded
Open this post in threaded view
|

Re: Basic Coding question, I do not recall seeing addressed in the literature

Eliot Miranda-2
Hi Timothy,

On Sat, Oct 24, 2020 at 3:32 AM gettimothy via Squeak-dev <[hidden email]> wrote:
Hi Folks,

Pardon the noobish "eyes of wonder" on the following. 

Recently, Eliot asked...
   what is the value of
      { (Float infinity basicAt: 1) hex.
        (Float infinity basicAt: 2) hex.
        (BoxedFloat64 infinity basicAt: 1) hex.
        (BoxedFloat64 infinity basicAt: 2) hex.
         BoxedFloat64 infinity == Float infinity }

The result is:


#('16r7FF00000' '16r0' '16r7FF00000' '16r0' true)
This shows that the stuff in an Array is evaluated BEFORE the array is "produced".

These are called Array Tuples, and Dan Ingalls added them to Squeak many years ago.  They are lovely concise forms, way more convenient than Array with: with: with: ... and not limited in size.  Since Dan adding them several dialects have followed suit.  Alas we've yet to see a new edition of the Blue Book to mention these and other great improvements (e.g. ByteArray literals, Vassili Bykov's ifNil:ifNotNil:, closures) although I do dream of doing a revised blue book with a modern VM specification in the last section.  And I'd love to see a Red Book on the Squeak tools.  Monticello is, for example, very beautiful, and should be more widely praised, used, and documented.

This is NOT in the Terse Guide and I do not recall seeing it in the books I read when I first started Squeak.

It should be :-)

It is a very handy tool.

I guess the behavior makes sense, as an Array is not a Block . Also, putting the same stuff in an OrderedCollection gives the same behavior.


|x|
x := OrderedCollection new.
x add:(Float infinity basicAt: 1) hex.
x add:(Float infinity basicAt: 2) hex.
x add:(BoxedFloat64 infinity basicAt: 1) hex.
x add:(BoxedFloat64 infinity basicAt: 2) hex.
x add: BoxedFloat64 infinity == Float infinity .
x inspect.


The construct is very reminiscent of on of the early lessons in the SICP series, 


Anyhoo, one more cool thing to add to the toolbox.

cheers.




--
_,,,^..^,,,_
best, Eliot


Reply | Threaded
Open this post in threaded view
|

Re: Basic Coding question, I do not recall seeing addressed in the literature

Squeak - Dev mailing list
Thanks Eliot


When Roassal3 side project is done, my attention turns to  either porting Pillar, or , more likeky, writing our own markdown parser with XTreams grammar and various  actor backends to duplicate the Pillar  output (including HelpBrowser, xhtml, latex, morse code...)


What I see being different is the source document living entirely within squeak classes, and storeable, distributable via monticello, with git being a secondary source of input to the monticello. Ergo, any squeak user can contribute by editing simple markup, or modifying existing templates.



The Array example  is in my  list of things to cover  .


So, suppose a couple of booklets exist covering Common Patterns and Idioms, Cool Code Snippets, Arrays,  etc...

A query to the in image documents for 'Array' will show those titles, edit and save in place, view in place, save via monticello, voila, every image has the documentation.

Squeak does not have a documentation problem, it has a documentation aggregation problem.  

Cheers