List Info

Thread: Re: Smalltalk scripting syntax




Re: Smalltalk scripting syntax
country flaguser name
United States
2007-03-13 19:12:15
For the class pool/class instance divide, why not take
advantage of
convention?

| InterROB protocolVersion dynamicInstance RecordNames |

where InterROB and RecordNames are class pool variables,
and
protocolVersion and dynamicInstance are class instance
variables.

On Tue, 2007-03-13 at 22:11 +0200, parasti wrote:
> Oh, you're right.  I left class instance variables out
of the picture.
> This is getting a bit confusing now...  I was trying to
figure out a way
> without hijacking the temporary variable declaration. 
I do think that
> it's better when all of the variables are explicitly
declared instead of
> having their definitions being scattered all over the
method definition
> scope.  (Or scopes!)  Well, class variables wouldn't,
anyway.  But I'd
> rather choose that than using the temporary variable
declaration
> literal.  I've gotten used to the idea that they're
"temporary" and
> conceptually only exist during execution of something. 
A lifetime of an
> object seems far too different to be called
"execution" of the object.

A recent example:

nextSkipUnrecognized: partialRecord
    "Answer a block that will read the rest of
partialRecord
     and deliver the content as an UnknownRecordType."
    | cont |
    ^cont := [:aConnection | | buffer |
	buffer := aConnection receiveBuffer.
	"I don't buffer the contentData myself, because it
simply has
	 to be buffered, and it might as well stay in aConnection
	 receiveBuffer."
	(buffer size - buffer position)
	    < partialRecord expectedDataSize
	    ifTrue: [cont]
	    ifFalse: [| content |
		      content := buffer next: partialRecord
expectedDataSize.
		      aConnection receivedHandledUpToHere.
		      aConnection unknownRecordType:
			  (partialRecord withContentData: content).
		      self nextSkipPadding: partialRecord
expectedPadding]]

Alternatively, using closures to persist tempvars is a
perfectly
reasonable way to implement an object system.  SICP includes
an example.

-- 
;;; Stephen Compall ** http://scompall.no
candysw.com/blog **
"Peta" is Greek for fifth; a petabyte is 10 to the
fifth power, as
well as fifth in line after kilo, mega, giga, and tera.
  -- Lee Gomes, performing every Wednesday in his tech
column
     "Portals" on page B1 of The Wall Street
Journal

_______________________________________________
help-smalltalk mailing list
help-smalltalkgnu.org

http://lists.gnu.org/mailman/listinfo/help-smalltalk

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )