Hi Folks,
I am migrating a package from Cog to Spur and I am getting errors that I suspect are related to it.
Here is an example:
|result|
result := pairs inject: first
into: [ :base :pair |
(pair first = 'round')
ifTrue: [
(pair last >= 0)
ifTrue:[
(base >=0)
ifTrue:["Cannot store into ->"base := base roundUpTo: ((1/10) raisedTo:(pair last truncated)) asFloat]
ifFalse:[base := base roundDownTo: ((1/10) raisedTo:(pair last truncated)) asFloat]]
ifFalse:[
(base >=0)
ifTrue:[
base := base roundDownTo: ((1/10) raisedTo:(pair last truncated)) asFloat]
ifFalse:[base := base roundUpTo: ((1/10) raisedTo:(pair last truncated)) asFloat]]]].
transcripton ifTrue:[Transcript show:'PHPRoundSimple ' , (result asFloat); cr. ].
^ result
Is this related to changes in Spur?
thx
t
There is a preference for this: Scanner allowBlockArgumentAssignment which false by default. However, I would rarely consider this good style; usually, it's a better idea to declare a separate temp var to keep arguments immutable. But if I did not misread your example, you do not need the assignments anyway - the into: block of #inject:into: just needs to answer the next accumulated value, and you already do this even if you do not reassign the block argument variable.
Best,
Christoph
________________________________ Von: Squeak-dev squeak-dev-bounces@lists.squeakfoundation.org im Auftrag von gettimothy via Squeak-dev squeak-dev@lists.squeakfoundation.org Gesendet: Dienstag, 9. November 2021 15:44:11 An: squeak-dev Betreff: [squeak-dev] Cannot store into-> (Is this related to changes in Spur)?
Hi Folks,
I am migrating a package from Cog to Spur and I am getting errors that I suspect are related to it.
Here is an example:
|result| result := pairs inject: first into: [ :base :pair | (pair first = 'round') ifTrue: [ (pair last >= 0) ifTrue:[ (base >=0) ifTrue:["Cannot store into ->"base := base roundUpTo: ((1/10) raisedTo:(pair last truncated)) asFloat] ifFalse:[base := base roundDownTo: ((1/10) raisedTo:(pair last truncated)) asFloat]] ifFalse:[ (base >=0) ifTrue:[ base := base roundDownTo: ((1/10) raisedTo:(pair last truncated)) asFloat] ifFalse:[base := base roundUpTo: ((1/10) raisedTo:(pair last truncated)) asFloat]]]].
transcripton ifTrue:[Transcript show:'PHPRoundSimple ' , (result asFloat); cr. ].
^ result
Is this related to changes in Spur?
thx
t
Hi Christoph
Thank you.
I too saw the uselessness of the attempted assignment and have removed them.
I agree also on the "style" issue as it makes my feeble brain ache less.
cordially,
---- On Wed, 10 Nov 2021 08:37:05 -0500 Thiede, Christoph Christoph.Thiede@student.hpi.uni-potsdam.de wrote ----
There is a preference for this: Scanner allowBlockArgumentAssignment which false by default. However, I would rarely consider this good style; usually, it's a better idea to declare a separate temp var to keep arguments immutable. But if I did not misread your example, you do not need the assignments anyway - the into: block of #inject:into: just needs to answer the next accumulated value, and you already do this even if you do not reassign the block argument variable.
Best,
Christoph
Von: Squeak-dev mailto:squeak-dev-bounces@lists.squeakfoundation.org im Auftrag von gettimothy via Squeak-dev mailto:squeak-dev@lists.squeakfoundation.org Gesendet: Dienstag, 9. November 2021 15:44:11 An: squeak-dev Betreff: [squeak-dev] Cannot store into-> (Is this related to changes in Spur)?
Hi Folks,
I am migrating a package from Cog to Spur and I am getting errors that I suspect are related to it.
Here is an example:
|result|
result := pairs inject: first
into: [ :base :pair |
(pair first = 'round')
ifTrue: [
(pair last >= 0)
ifTrue:[
(base >=0)
ifTrue:["Cannot store into ->"base := base roundUpTo: ((1/10) raisedTo:(pair last truncated)) asFloat]
ifFalse:[base := base roundDownTo: ((1/10) raisedTo:(pair last truncated)) asFloat]]
ifFalse:[
(base >=0)
ifTrue:[
base := base roundDownTo: ((1/10) raisedTo:(pair last truncated)) asFloat]
ifFalse:[base := base roundUpTo: ((1/10) raisedTo:(pair last truncated)) asFloat]]]].
transcripton ifTrue:[Transcript show:'PHPRoundSimple ' , (result asFloat); cr. ].
^ result
Is this related to changes in Spur?
thx
t
squeak-dev@lists.squeakfoundation.org