As there was a recent discussion about the Smalltalk Syntax in a Postcard, i added a contest on the Stackoverflow Programming Puzzles & Code Golf site:
http://codegolf.stackexchange.com/questions/33050/smalltalk-syntax-in-a-postcard-that-actually-does-something-interesting |
Yes I would love to have a method doing something useful and showing the
complete syntax ") On 6/7/14 18:16, MartinW wrote: > As there was a recent discussion about the Smalltalk Syntax in a Postcard, i > added a contest on the Stackoverflow Programming Puzzles & Code Golf site: > http://codegolf.stackexchange.com/questions/33050/smalltalk-syntax-in-a-postcard-that-actually-does-something-interesting > > > > -- > View this message in context: http://forum.world.st/Smalltalk-Syntax-in-a-Postcard-contest-tp4766793.html > Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com. > > > |
In reply to this post by MartinW
The contest is gone? Anyway, the closest useful method I have found by iterating all ASTs in standard 3.0 image :- Has keyword messages
- Has super messagesand this is the winner: RBMessageNode>>replaceSourceWithMessageNode: aNode | isBinaryToKeyword | self numArgs = aNode numArgs ifFalse: [^super replaceSourceWith: aNode]. self arguments with: aNode arguments do: [:old :new | (self mappingFor: old) = new ifFalse: [^super replaceSourceWith: aNode]]. (self mappingFor: self receiver) = aNode receiver ifFalse: [(self receiver isVariable and: [aNode receiver isVariable]) ifFalse: [^super replaceSourceWith: aNode]. self addReplacement: (RBStringReplacement replaceFrom: self receiver start to: self receiver stop with: aNode receiver name)]. (isBinaryToKeyword := self isBinary and: [aNode isKeyword]) ifTrue: [(self hasParentheses not and: [self parent precedence <= aNode precedence]) ifTrue: [self addReplacement: (RBStringReplacement replaceFrom: self start to: self start - 1 with: '('); addReplacement: (RBStringReplacement replaceFrom: self stop + 1 to: self stop with: ')')]]. self selectorParts with: aNode selectorParts do: [:old :new | old value ~= new value ifTrue: [self addReplacement: (RBStringReplacement replaceFrom: old start to: old stop with: ((isBinaryToKeyword and: [(self source at: old start - 1) isSeparator not]) ifTrue: [' ' , new value] ifFalse: [new value]))]] Cheers, Hernán 2014-07-06 13:16 GMT-03:00 MartinW <[hidden email]>: As there was a recent discussion about the Smalltalk Syntax in a Postcard, i |
Sometimes StackExchange-related guys are really stupid… I think that we should put this contest in a visible place. And thanks Hernán, I think that it’s also cool that you can search for desired method like that in the image.
Uko
On 08 Jul 2014, at 09:07, Hernán Morales Durand <[hidden email]> wrote:
|
On 8 July 2014 08:12, Yuriy Tymchuk <[hidden email]> wrote:
> Sometimes StackExchange-related guys are really stupid… That missing contest page has this: "This question was voluntarily removed by its author." frank > Uko |
On 08 Jul 2014, at 11:08, Frank Shearar <[hidden email]> wrote: > On 8 July 2014 08:12, Yuriy Tymchuk <[hidden email]> wrote: >> Sometimes StackExchange-related guys are really stupid… > > That missing contest page has this: "This question was voluntarily > removed by its author.” No, the thing is that I followed discussion when the question was present. They had a valid question that maybe wasn’t perfect in terms of site, but they could get some impact from it. Now they don’t have it. Once I proposed a new Q/A site, and proposal was quite popular. Now they don’t have it… Uko > > frank > >> Uko > |
In reply to this post by hernanmd
I removed the question, but only after it was already marked to be closed by several people. Their argument was, that the question was "to broad". Once a discussion like this starts on Stackexchange sites there's always a herd behavior that's hard to stop.
Can you share the code you used for your search, Hernán?
|
Hello Martin, I have refined the search a little bit, and we have a new winner with Stephane Ducasse as author in annotations. PSMCMergeMorph>>model: aMerger "Set the model and update the window." |grouped sorted| super model: aMerger. grouped := aMerger operations groupBy: [:o | o targetClassName ifNil: [o shortSummary]] having: [:g | true]. sorted := OrderedCollection new. grouped keys asSortedCollection do: [:k | sorted addAll: ((grouped at: k) asSortedCollection: [:a :b | a shortSummary <= b shortSummary])]. self patchMorph model: sorted
This is the code I have used: | allMethods | allMethods := SystemNavigation default allMethods. UIManager default displayProgress: 'Scanning all methods...' from: 1 to: allMethods size during: [ : bar | | current | current := 0. allMethods select: [ : each | current := current + 1. bar value: current. each ast arguments notEmpty and: [ (each ast allChildren anySatisfy: #isAssignment) and: [ (each ast allChildren anySatisfy: #isBlock) and: [ each ast temporaries notEmpty and: [ each ast superMessages notEmpty and: [ (each ast allChildren anySatisfy: [ : node | node isMessage and: [ node selector isUnary ] ]) and: [ (each ast allChildren anySatisfy: [ : node | node isMessage and: [ node selector isBinary ] ]) and: [ (each ast allChildren anySatisfy: [ : node | node isBlock and: [ node arguments size = 2] ]) and: [ (each ast allChildren anySatisfy: [ : node | node isBlock and: [ node arguments size = 1] ]) ] ] ] ] ] ] ] ] ] ]. Cheers, Hernán 2014-07-08 18:48 GMT-03:00 MartinW <[hidden email]>: I removed the question, but only after it was already marked to be closed by |
I forgot to add which in that case, there is no method in the Pharo 3 image. Maybe a package out there...each ast allChildren anySatisfy: [ : node | node isCascade ] Anyway, who can load all packages? :) PS: One problem with StackExchange is there are very few smalltalkers registered. 2014-07-08 21:20 GMT-03:00 Hernán Morales Durand <[hidden email]>:
|
Free forum by Nabble | Edit this page |