[Vm-dev] reorganizing opensmalltalk-vm

Levente Uzonyi leves at caesar.elte.hu
Mon Oct 29 19:03:41 UTC 2018


On Fri, 26 Oct 2018, Tobias Pape wrote:

> Think I have a method with a very long selector, eg MCClassDefinition:
>
>
> initializeWithName: nameString
> superclassName: superclassString
> traitComposition: traitCompositionString
> classTraitComposition: classTraitCompositionString
> category: categoryString 
> instVarNames: ivarArray
> classVarNames: cvarArray
> poolDictionaryNames: poolArray
> classInstVarNames: civarArray
> type: typeSymbol
> comment: commentString
> commentStamp: stampStringOrNil
> 	name := nameString asSymbol.
> 	superclassName := superclassString ifNil: ['nil'] ifNotNil: [superclassString asSymbol].
> 	traitComposition := traitCompositionString.
> 	classTraitComposition := classTraitCompositionString.
> 	category := categoryString.
> 	type := typeSymbol.
> 	comment := commentString withSqueakLineEndings.
> 	commentStamp := stampStringOrNil ifNil: [self defaultCommentStamp].
> 	variables := OrderedCollection  new.
> 	self addVariables: ivarArray ofType: MCInstanceVariableDefinition.
> 	self addVariables: cvarArray sorted ofType: MCClassVariableDefinition.
> 	self addVariables: poolArray sorted ofType: MCPoolImportDefinition.
> 	self addVariables: civarArray ofType: MCClassInstanceVariableDefinition
>
>
> Seeing the Tonel format, this formatting of the selector, even if it is uncommon, would not be preserved, right?

I just checked, and the formatting is preserved, even comments and white 
spaces between the selector part and the argument names appear as written.
The only nuance is that no parser can optimally separate the method body 
from its signature, so there are edge cases with unexpected results. E.g.:

If you add type information as comments like below, the last comment will 
appear if it were part of the method body:

Object >> foo: foo "Integer" bar: bar "String"

 	^foo asString, bar

will be stored as

Object >> foo: foo "Integer" bar: bar [ "String"

 	^foo asString, bar
]

Levente


More information about the Vm-dev mailing list