Hi,
I can't figure this one out - is the value of /complete / in #ifCurtailed
method used somewhere?
Very confusing ;) Thanks a lot!
Jaromir
ifCurtailed: aBlock
| complete result |
<primitive: 198>
result := self valueNoContextSwitch.
complete := true.
^result
--
Sent from: http://forum.world.st/Squeak-Dev-f45488.html
Hi Folks,
I am importing my grammar/xtreams parsing work into its own image so that I can change my system fonts without making my other projects look funky with the chages.
The base image is:
Image
-----
/home/wm/usr/src/smalltalk/squeak6.0alpha/shared/Squeak6.0alpha-19802-64bit.image
Squeak6.0alpha
latest update: #20147
to the latest:
/home/wm/Squeak/images/WikitextParser/WikitextParser.image
Squeak6.0alpha
latest update: #20188
During the import of my work, I ran into this issue regarding Store Into in a block:
http://forum.world.st/Cuis-problem-with-blocks-td1047783.html#a1049556
The parser is looking for patterns of (10e2)e2....i.e. exponential notation of unknown length, i.e. per the comment on Collection inject: into: accumulate a running value...
Per the email chain referenced, the "Allow block argument assignment" is allowed in the former, and not allowed in the latest, which is cool with me, but...
My question is "what is the generic form" that I can use to duplicate the behaviour I want?
Here is the original method with the bad store into:
Float: first exponent: pairs
<action: 'Float' arguments:#(1 2)>
"Float <- ( Number / Group / Function ) (''e'' ( Number / Group / Function ))+"
|result|
result := pairs inject: first
into: [ :base :pair |
(pair first = 'e')
ifTrue: [
(pair last abs > 1)
ifTrue:[ base := Float readFrom: ((base asString) , 'e', (pair last asString))]
ifFalse:[ base := (base * (10 raisedTo:(pair last) ))]]].
transcripton ifTrue:[Transcript show:'Float ' , (result asFloat); cr. ].
^ result asFloat
Here is my "hack" to fix it , (I create a tmp variable outside the block to use in place of the "base"):
Float: first exponent: pairs
<action: 'Float' arguments:#(1 2)>
"Float <- ( Number / Group / Function ) (''e'' ( Number / Group / Function ))+"
|result tmp|
result := pairs inject: first
into: [ :base :pair |
(pair first = 'e')
ifTrue: [
(pair last abs > 1)
ifTrue:[tmp := base.
tmp := Float readFrom: ((tmp asString) , 'e', (pair last asString))]
tmp := Float readFrom: ((tmp asString) , 'e', (pair last asString)).
tmp]
ifFalse:[tmp := base.
tmp := (tmp * (10 raisedTo:(pair last) ))]]].
tmp := (tmp * (10 raisedTo:(pair last) )).
tmp]]].
transcripton ifTrue:[Transcript show:'Float ' , (result asFloat); cr. ].
^ result asFloat
I got a bad feeling about this one.
Is there a general form for this ?
My brain is a bit foggy from working the graveyard shift so what would be obvious while in normal conditions , is not obvious today.
Thanks for you time.
Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-nice.1368.mcz
==================== Summary ====================
Name: Kernel-nice.1368
Author: nice
Time: 11 February 2021, 9:30:07.084854 am
UUID: b086833d-ece4-4372-b252-87d2caa59193
Ancestors: Kernel-eem.1367
Rescue setting of Processor highestPriority: anInteger
There was a double problem:
1) if reducing the priority, then anyProcessesAbove: did behave as noProcessAbove: because (select:) isEmpty <=> noneSatisfy:
It should have been (reject:) empty or (select:) notEmpty, but we have anySatisfy: for expressing this intention
2) if increasing the priority, then the loop did overwrite the last LinkedList in the quiescentProcessLists
Those LinkedList are mostly empty in my own image, and we never change the highestPriority, so the bug was probably benign...
=============== Diff against Kernel-eem.1367 ===============
Item was changed:
----- Method: ProcessorScheduler>>anyProcessesAbove: (in category 'private') -----
anyProcessesAbove: highestPriority
+ "Do any (sub) instances of Process exist with higher priorities?"
- "Do any instances of Process exist with higher priorities?"
+ ^(Process allSubInstances anySatisfy: [:aProcess |
+ aProcess priority > highestPriority])!
- ^(Process allSubInstances select: [:aProcess |
- aProcess priority > highestPriority]) isEmpty
- "If anyone ever makes a subclass of Process, be sure to use allSubInstances."!
Item was changed:
----- Method: ProcessorScheduler>>highestPriority: (in category 'accessing') -----
highestPriority: newHighestPriority
"Change the number of priority levels currently available for use."
| newProcessLists |
(quiescentProcessLists size > newHighestPriority
and: [self anyProcessesAbove: newHighestPriority])
ifTrue: [self error: 'There are processes with priority higher than '
,newHighestPriority printString].
newProcessLists := Array new: newHighestPriority.
+ 1 to: (quiescentProcessLists size min: newProcessLists size) do:
- 1 to: ((quiescentProcessLists size) min: (newProcessLists size)) do:
[:priority | newProcessLists at: priority put: (quiescentProcessLists at: priority)].
+ quiescentProcessLists size + 1 to: newProcessLists size do:
- (quiescentProcessLists size max: 1) to: newProcessLists size do:
[:priority | newProcessLists at: priority put: LinkedList new].
quiescentProcessLists := newProcessLists!
A new version of KernelTests was added to project The Inbox:
http://source.squeak.org/inbox/KernelTests-jar.393.mcz
==================== Summary ====================
Name: KernelTests-jar.393
Author: jar
Time: 8 February 2021, 10:06:09.126403 pm
UUID: af94938b-d43a-b94c-b306-922ab65afb78
Ancestors: KernelTests-eem.392
Test for Process>>priority: related to fix Kernel-jar.1368
=============== Diff against KernelTests-eem.392 ===============
Item was added:
+ ----- Method: ProcessTest>>testPriority (in category 'tests') -----
+ testPriority
+ "test whether #priority: preempts active process to allow higher priority processes run"
+
+ | val oldPriority |
+ val := nil.
+ oldPriority := Processor activePriority.
+ Processor activeProcess priority: oldPriority + 2.
+ [ val := false ] forkAt: oldPriority + 1.
+ [ val := true ] forkAt: oldPriority.
+ Processor activeProcess priority: oldPriority.
+ self assert: val equals: Smalltalk vm processPreemptionYields!