Chris Muller uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-cmm.606.mcz
==================== Summary ====================
Name: System-cmm.606
Author: cmm
Time: 25 October 2013, 10:41:38.197 am
UUID: 6a901946-a756-42d8-a453-f727b8dfad32
Ancestors: System-dtl.605
- Correct initialization of RecentMessages in case a new instance is ever made (and for the test cases).
- Fix revertMostRecent.
=============== Diff against System-dtl.605 ===============
Item was changed:
----- Method: RecentMessages>>initialize (in category 'initialize-release') -----
initialize
super initialize.
+ methodReferences := OrderedCollection new: (maximumSubmissionCount := 30).
+ isSuspended := false!
- methodReferences := OrderedCollection new: 30!
Item was changed:
----- Method: RecentMessages>>revertMostRecent (in category 'accessing') -----
revertMostRecent
"If the most recent method submission was a method change, revert
that change, and if it was a submission of a brand-new method,
remove that method."
| changeRecords lastSubmission theClass theSelector |
methodReferences ifEmpty: [ ^ Beeper beep ].
+ lastSubmission := self mostRecent.
- lastSubmission := methodReferences last.
theClass := lastSubmission actualClass ifNil: [ ^ Beeper beep ].
theSelector := lastSubmission methodSymbol.
changeRecords := theClass changeRecordsAt: theSelector.
changeRecords isEmptyOrNil ifTrue: [ ^ Beeper beep ].
changeRecords size = 1
ifTrue: [ "method has no prior version, so reverting in this case means removing"
theClass removeSelector: theSelector ]
ifFalse: [ changeRecords second fileIn ]
!
Hi guys. Levente, thanks for the reminder about running the tests. I
do run them sometimes, but not as part of commit, especially if some
commit has affected my IDE negatively; I'm not committing to going the
full mile in that situation as much as simply keeping the tools
working so I can work.
I think it would be great if we could get CI sending e-mails; with
some good filtering rules and perhaps also to a new, separate list, so
that trunk slammers can be appropriately spanked.
This may be another reason to consider we as a community might want
the ability to send mail; the other being that our reliance on box2
costs money.
Frank, please pardon if I've been heavy-handed by saying
#recordSelector:forClass:inEnvironment: does not need to return a
value without consulting with you first. I sometimes actually like to
leave tests failing as a means of stirring discussion, (and CI emails
could get the ball rolling). I wanted to respond responsibly to
Levente too, though.
There is still one test failing but I'm not sure why. If you know we
can put RecentMessages to bed?
On Thu, Oct 24, 2013 at 8:32 PM, <commits(a)source.squeak.org> wrote:
> Chris Muller uploaded a new version of Tests to project The Trunk:
> http://source.squeak.org/trunk/Tests-cmm.258.mcz
>
> ==================== Summary ====================
>
> Name: Tests-cmm.258
> Author: cmm
> Time: 24 October 2013, 8:32:17.751 pm
> UUID: e68974a5-6e3b-451b-be6f-dc8bb41e8577
> Ancestors: Tests-cmm.257
>
> - RecentMessagesTest updated for recent updates.
> - Support the notion that deletion of a message is worth keeping in RecentMessages. In the future I'd like to see the ability to browse versions on removed methods so they can be restored right from there.
> - #recordSelector:forClass:inEnvironment: is basically a private method. No senders of it ever consume its return value. If there is no requirement for it to return anything, it shouldn't.
>
> =============== Diff against Tests-cmm.257 ===============
>
> Item was changed:
> ----- Method: RecentMessagesTest>>testMaximumSubmissionCountDefaultsToTen (in category 'testing') -----
> testMaximumSubmissionCountDefaultsToTen
> + self assert: 30 equals: rm maximumSubmissionCount.!
> - self assert: 10 equals: rm maximumSubmissionCount.!
>
> Item was changed:
> ----- Method: RecentMessagesTest>>testMethodReferencesReturnsAllSubmissions (in category 'testing') -----
> testMethodReferencesReturnsAllSubmissions
> | expected |
> expected := {
> + MethodReference class: Utilities selector: #bar environment: env.
> + MethodReference class: Utilities selector: #foo environment: env }.
> - MethodReference class: Utilities selector: #foo environment: env.
> - MethodReference class: Utilities selector: #bar environment: env}.
> rm recordSelector: #foo forClass: Utilities inEnvironment: env.
> rm recordSelector: #bar forClass: Utilities inEnvironment: env.
> + self assert: expected equals: rm methodReferences!
> - self assert: expected equals: rm methodReferences.!
>
> Item was removed:
> - ----- Method: RecentMessagesTest>>testMostRecentReturnsLastExtantReference (in category 'testing') -----
> - testMostRecentReturnsLastExtantReference
> - | victim |
> - victim := self createClass: #Victim.
> - victim compile: 'foo ^ 1'.
> - victim compile: 'bar ^ 1'.
> - rm recordSelector: #foo forClass: victim inEnvironment: env.
> - rm recordSelector: #bar forClass: victim inEnvironment: env.
> - victim removeSelector: #bar.
> - self assert: #foo equals: rm mostRecent selector.!
>
> Item was added:
> + ----- Method: RecentMessagesTest>>testMostRecentReturnsRemovedReference (in category 'testing') -----
> + testMostRecentReturnsRemovedReference
> + | victim |
> + victim := self createClass: #Victim.
> + victim compile: 'foo ^ 1'.
> + victim compile: 'bar ^ 1'.
> + rm recordSelector: #foo forClass: victim inEnvironment: env.
> + rm recordSelector: #bar forClass: victim inEnvironment: env.
> + victim removeSelector: #bar.
> + self assert: #bar equals: rm mostRecent selector.!
>
> Item was removed:
> - ----- Method: RecentMessagesTest>>testRecordSelectorForClassInEnvironmentAlwaysReturnsMethodReference (in category 'testing') -----
> - testRecordSelectorForClassInEnvironmentAlwaysReturnsMethodReference
> - | r |
> - WantsChangeSetLogging no.
> - r := rm recordSelector: #foo forClass: WantsChangeSetLogging inEnvironment: Smalltalk globals.
> - self assert: MethodReference equals: r class description: 'Even when not logging, always return a MethodReference'.!
>
> Item was removed:
> - ----- Method: RecentMessagesTest>>testRecordSelectorForClassInEnvironmentReturnsMethodReference (in category 'testing') -----
> - testRecordSelectorForClassInEnvironmentReturnsMethodReference
> - | r sel class env |
> - sel := #foo.
> - class := self class.
> - env := self class environment.
> - r := rm recordSelector: sel forClass: class inEnvironment: env.
> - self assert: sel equals: r selector.
> - self assert: class equals: r actualClass.
> - self assert: env equals: r environment.
> -
> - self assert: r equals: (rm recordSelector: sel forClass: class inEnvironment: env).!
>
>
Hi,
I'm about to write a method where I need to test whether to do something or
just get out. What is the best practices way to do this? For example:
(a = b) ifTrue: [^nil].
*The code that does the work*
or:
(a = b) ifFalse: [
*The code that does the work*
].
I think the second is better style but I have used both. Generally using
the first when *The code that does the work* is long and the second when it
is short.
Is there any speed difference between them? I doubt it but I thought I
would ask anyway.
Lou
-----------------------------------------------------------
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon
mailto:Lou@Keystone-Software.com http://www.Keystone-Software.com
How could one resist?
(In case it isn't readable, the yellow 'caution' says "Caution: squeaking may occur!")
tim
--
tim Rowledge; tim(a)rowledge.org; http://www.rowledge.org/tim
"Bother" said Pooh, as he flunked the the sobriety test.
On Fri, 25 Oct 2013, Nicolas Cellier wrote:
> Hard to debug this kind of code :(
> This is reproducible on Squeak wiht on:do:, so on:fork: bizareness apart, this is another flaw in exception handling, along with wrong handler for nested exception (testHandlerFromAction below), unless it's
> an avatar.
>
> Still, I do not see how you get the errorSubscriptBound:...
> In Squeak that would mean that you sent #handleSignal: to a not isHandlerContext ContextPart...
> I never saw this, but if Eliot says so...
>
>
>
> ExceptionTests>>testHandlerFromAction
> "A test ensuring that nested exceptions work as expected."
>
> | result |
> result := [
> [
> [self error: 'trigger error'] on: ZeroDivide do: [ :ex | 'inner' ]
> ] on: Error do: [ :ex | 3 / 0 ]
> ] on: ZeroDivide do: [ :ex | 'outer' ].
> self assert: 'outer' equals: result description: 'Incorrect handler'.
I had an attempt to fix it, but it's incomplete, and other issues popped
up:
http://lists.squeakfoundation.org/pipermail/squeak-dev/2012-August/165364.h…
Levente
>
>
>
> 2013/10/24 Igor Stasenko <siguctua(a)gmail.com>
>
> ok, it seems i found how to reproduce the situation with following:
>
> [ [ 1/0 ] ensure: [ nil foo ] ] on: Error fork: [ :ex | 1halt ]
>
> you will get halt, and if you close the debugger , it will throw unwind error.
> (while instead it should throw DNU)
>
>
> --
> Best regards,
> Igor Stasenko.
>
>
>
>
Changes to Trunk (http://source.squeak.org/trunk.html) in the last 24 hours:
http://lists.squeakfoundation.org/pipermail/packages/2013-October/006553.ht…
Name: Kernel-ul.812
Ancestors: Kernel-nice.811, Kernel-ul.811
- merged Kernel-ul.811 with the changes to Random
- use the #environment message to access the environment from Class, instead of the variable named environment, because the latter might be nil, which causes an error during update
=============================================
On Tue, 15 Oct 2013, commits(a)source.squeak.org wrote:
> Chris Muller uploaded a new version of System to project The Trunk:
> http://source.squeak.org/trunk/System-cmm.602.mcz
>
> ==================== Summary ====================
>
> Name: System-cmm.602
> Author: cmm
> Time: 15 October 2013, 1:45:33.881 pm
> UUID: 7a452144-3c88-4726-9692-a6afa93ef46e
> Ancestors: System-eem.601
>
> - Support Preferences class>>#readDocumentAtStartup: false, so that Squeak can accept arbitrary arguments without requiring the first one to be a document URL.
> - Convenience method for checking for any of the various headless VM options.
> - API consistency for accessing command-line arguments.
> - Remove duplicate code (#extractParameters). Bid to remove apparently-unused code.
> - RecentMessages simplifications, fixes and cleanups.
I get 13 errors, and 2 failures from RecentMessagesTest after these
changes. 10 of them are related to the fact, that #initialize doesn't
initialize all instance variables.
Some of the tests got broken earlier in System-cmm.600.
I think that the CI should send emails to this list (preferrably when a
test starts failing which wasn't failing before), because it seems like
nobody is running the tests in the image anymore, using the (weak)
excuse that the CI will do it anyway. But nobody checks the CI either.
Another option is to go back to our previous policy "run all the tests
before you commit". But it didn't work, and that's one of the reasons why
the CI was created.
Levente
Levente Uzonyi uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-ul.812.mcz
==================== Summary ====================
Name: Kernel-ul.812
Author: ul
Time: 24 October 2013, 6:20:30.715 pm
UUID: c9549364-8b71-4105-ac51-cff717cd57ee
Ancestors: Kernel-nice.811, Kernel-ul.811
- merged Kernel-ul.811 with the changes to Random
- use the #environment message to access the environment from Class, instead of the variable named environment, because the latter might be nil, which causes an error during update
=============== Diff against Kernel-nice.811 ===============
Item was changed:
----- Method: Class>>removeClassVarName: (in category 'class variables') -----
removeClassVarName: aString
"Remove the class variable whose name is the argument, aString, from
the names defined in the receiver, a class. Create an error notification if
aString is not a class variable or if it is still being used in the code of
the class."
| aSymbol |
aSymbol := aString asSymbol.
(classPool includesKey: aSymbol)
ifFalse: [^self error: aString, ' is not a class variable'].
self withAllSubclasses do:[:subclass |
(Array with: subclass with: subclass class) do:[:classOrMeta |
(classOrMeta whichSelectorsReferTo: (classPool associationAt: aSymbol))
isEmpty ifFalse: [
InMidstOfFileinNotification signal ifTrue: [
Transcript cr; show: self name, ' (' , aString , ' is Undeclared) '.
+ ^self environment undeclared declare: aSymbol from: classPool].
- ^ environment undeclared declare: aSymbol from: classPool].
(self confirm: (aString,' is still used in code of class ', classOrMeta name,
'.\Is it okay to move it to Undeclared?') withCRs)
ifTrue:[^Undeclared declare: aSymbol from: classPool]
ifFalse:[^self]]]].
classPool removeKey: aSymbol.
classPool isEmpty ifTrue: [classPool := nil].
!
Item was changed:
----- Method: Class>>rename: (in category 'class name') -----
rename: aString
"The new name of the receiver is the argument, aString."
| oldName newName |
(newName := aString asSymbol) = (oldName := self name)
ifTrue: [^ self].
(self environment includesKey: newName)
ifTrue: [^ self error: newName , ' already exists'].
+ (self environment undeclared includesKey: newName)
- (environment undeclared includesKey: newName)
ifTrue: [self inform: 'There are references to ' , aString printString , '
from Undeclared. Check them after this change.'].
name := newName.
self environment renameClass: self from: oldName!
Item was changed:
Object subclass: #Random
+ instanceVariableNames: 'seed'
+ classVariableNames: 'A M Q R'
- instanceVariableNames: 'seed a m q r'
- classVariableNames: ''
poolDictionaries: ''
category: 'Kernel-Numbers'!
!Random commentStamp: 'nice 3/24/2010 07:38' prior: 0!
This Random Number Generator graciously contributed by David N. Smith. It is an adaptation of the Park-Miller RNG which uses Floats to avoid the need for LargeInteger arithmetic.
If you just want a quick random integer, use:
10 atRandom
Every integer interval can give a random number:
(6 to: 12) atRandom
SequenceableCollections can give randomly selected elements:
'pick one of these letters randomly' atRandom
SequenceableCollections also respond to shuffled, as in:
($A to: $Z) shuffled
The correct way to use class Random is to store one in an instance or class variable:
myGenerator := Random new.
Then use it every time you need another number between 0.0 and 1.0 (excluding)
myGenerator next
You can also generate a positive integer
myGenerator nextInt: 10!
Item was changed:
----- Method: Random class>>bucketTest: (in category 'testing') -----
bucketTest: randy
"Execute this: Random bucketTest: Random new"
" A quick-and-dirty bucket test. Prints nbuckets values on the
Transcript.
Each should be 'near' the value of ntries. Any run with any value
'far' from ntries
indicates something is very wrong. Each run generates different
values.
For a slightly better test, try values of nbuckets of 200-1000 or
more; go get coffee.
This is a poor test; see Knuth. Some 'OK' runs:
1000 1023 998 969 997 1018 1030 1019 1054 985 1003
1011 987 982 980 982 974 968 1044 976
1029 1011 1025 1016 997 1019 991 954 968 999 991
978 1035 995 988 1038 1009 988 993 976
"
| nbuckets buckets ntrys |
+ nbuckets := 200.
- nbuckets := 20.
buckets := Array new: nbuckets.
buckets atAllPut: 0.
+ ntrys := 1000.
- ntrys := 100.
ntrys*nbuckets timesRepeat: [ | slot |
slot := (randy next * nbuckets) floor + 1.
buckets at: slot put: (buckets at: slot) + 1 ].
Transcript cr.
1 to: nbuckets do: [ :nb |
Transcript show: (buckets at: nb) printString, ' ' ]!
Item was added:
+ ----- Method: Random class>>initialize (in category 'class initialization') -----
+ initialize
+ "Initialize the magic constants. All instances share these values. Use floats to avoid LargeInteger computations (it still gives about 3-4x speedup)."
+
+ A := 16807.0. " magic constant = 16807 "
+ M := 2147483647.0. " magic constant = 2147483647 "
+ Q := 127773.0. "(m quo: a) asFloat."
+ R := 2836.0 "(m \\ a) asFloat."!
Item was changed:
----- Method: Random class>>seed: (in category 'instance creation') -----
seed: anInteger
+ ^self basicNew seed: anInteger!
- ^self new seed: anInteger!
Item was changed:
----- Method: Random>>initialize (in category 'initialization') -----
initialize
+
+ | hash |
+ hash := self hash.
+ "Set a reasonable Park-Miller starting seed"
+ seed := Time primUTCMicrosecondClock.
+ seed = 0 ifFalse: [ "Use the microsecond clock if possible."
+ seed := (seed bitAnd: 16r3FFFFFFF) bitXor: hash ].
+ [ seed = 0 ] whileTrue: [ "Try again if ever get a seed = 0, or there's no microsecond clock."
+ seed := (Time millisecondClockValue bitAnd: 16r3FFFFFFF) bitXor: hash ]!
- " Set a reasonable Park-Miller starting seed "
- [seed := (Time millisecondClockValue bitAnd: 16r3FFFFFFF) bitXor: self hash.
- seed = 0] whileTrue: ["Try again if ever get a seed = 0"].
-
- a := 16r000041A7 asFloat. " magic constant = 16807 "
- m := 16r7FFFFFFF asFloat. " magic constant = 2147483647 "
- q := (m quo: a) asFloat.
- r := (m \\ a) asFloat.
- !
Item was changed:
----- Method: Random>>next (in category 'accessing') -----
next
"Answer a random Float in the interval [0 to 1)."
+ ^ (seed := self nextValue) / M!
- ^ (seed := self nextValue) / m!
Item was changed:
----- Method: Random>>nextValue (in category 'private') -----
nextValue
"This method generates random instances of Integer in the interval
0 to 16r7FFFFFFF. This method does NOT update the seed; repeated sends
answer the same value.
The algorithm is described in detail in 'Random Number Generators:
Good Ones Are Hard to Find' by Stephen K. Park and Keith W. Miller
(Comm. Asso. Comp. Mach., 31(10):1192--1201, 1988)."
| lo hi aLoRHi answer |
+ hi := (seed quo: Q) asFloat.
+ lo := seed - (hi * Q). " = seed rem: q"
+ aLoRHi := (A * lo) - (R * hi).
- hi := (seed quo: q) asFloat.
- lo := seed - (hi * q). " = seed rem: q"
- aLoRHi := (a * lo) - (r * hi).
answer := (aLoRHi > 0.0)
ifTrue: [aLoRHi]
+ ifFalse: [aLoRHi + M].
- ifFalse: [aLoRHi + m].
^ answer!