[squeak-dev] The Inbox: Collections-ul.564.mcz
Tobias Pape
Das.Linux at gmx.de
Mon Feb 3 15:06:22 UTC 2014
On 03.02.2014, at 16:01, Frank Shearar <frank.shearar at gmail.com> wrote:
> On 3 February 2014 14:49, Tobias Pape <Das.Linux at gmx.de> wrote:
>> On 03.02.2014, at 15:28, Frank Shearar <frank.shearar at gmail.com> wrote:
>>
>>> On 3 February 2014 13:48, <commits at source.squeak.org> wrote:
>>>> A new version of Collections was added to project The Inbox:
>>>> http://source.squeak.org/inbox/Collections-ul.564.mcz
>>>>
>>>> ==================== Summary ====================
>>>>
>>>> Name: Collections-ul.564
>>>> Author: ul
>>>> Time: 3 February 2014, 2:35:36.802 pm
>>>> UUID: 4b9a37ef-df86-40a0-a0dd-8e8b2c04d4ed
>>>> Ancestors: Collections-ul.563
>>>>
>>>> Make sure that Array >> #isLiteral won't get into an infinite recursion, even if the receiver has an recursive structure.
>>>>
>>>> =============== Diff against Collections-ul.563 ===============
>>>>
>>>> Item was changed:
>>>> ----- Method: Array>>isLiteral (in category 'testing') -----
>>>> isLiteral
>>>> +
>>>> + ^self class == Array and: [
>>>> + self isLiteralIfContainedBy: IdentitySet new ]!
>>>> - ^self class == Array and: [self allSatisfy: [:each | each isLiteral]]!
>>>>
>>>> Item was added:
>>>> + ----- Method: Array>>isLiteralIfContainedBy: (in category 'testing') -----
>>>> + isLiteralIfContainedBy: parents
>>>> + " Answer whether the receiver has a literal text form recognized by the compiler. Precondition: the receiver is an instance of Array. "
>>>> +
>>>> + (parents includes: self) ifTrue: [ ^false ].
>>>> + parents add: self.
>>>> + 1 to: self size do: [ :index |
>>>> + | element |
>>>> + element := self at: index.
>>>> + (element class == Array
>>>> + ifTrue: [ element isLiteralIfContainedBy: parents ]
>>>> + ifFalse: [ element isLiteral ]) ifFalse: [ ^false ] ].
>>>> + parents remove: self.
>>>> + ^true!
>>>
>>> So this is a basic depth first traversal with cycle protection, yes?
>>> (This pattern seems to crop up _a lot_. Maybe it's worth pulling out
>>> as a separate algorithm?)
>>
>> Well, there are two such applications:
>> One with an explicit down-handling of a variable (like this)
>> and one with an implicit variable (semi-global)
>> (Dynamic variable, probably, at least thread-local)
>>
>> I would like to have both.
>> I propose the (seaside-inspired) #use:during: message for the second.
>
> Except that DynamicVariable's #use:during: is incompatible with
> stack-slicing, because those kinds of dynamic variables aren't
> delimited. (Unlike resumable exceptions, for instance.
Sorry, I (currently) don’t know what you mean by stack-slicing.
Are we speaking of Martin von Löwis’ DynamicVariables currently in 4.5/trunk
that are based on Thread-local storage
or the Seaside ones based on Exceptions?
(I just see that DV is using #value:during: rather than #use:during:
the former is consistent while the latter IMHO speaks better)
>> However I cannot imagine a generic message for the first variant.
>
> myArray depthFirstDo: [:each | each doSomething] havingVisited:
> IdentitySet new ?
Sounds squeakish :)
Best
-Tobias
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 1665 bytes
Desc: Message signed with OpenPGP using GPGMail
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20140203/388971ae/signature.pgp
More information about the Squeak-dev
mailing list
|