开发者

Is there a way to note type at each message parameters on Smalltalk? (like Objective-C)

开发者 https://www.devze.com 2023-03-12 04:49 出处:网络
Objective-C is a language like Smalltalk, but weakly, dynamically typed language. And I can note type of each message parameter at in-place optionally.

Objective-C is a language like Smalltalk, but weakly, dynamically typed language. And I can note type of each message parameter at in-place optionally.

It's important as a kind of documentation (at least for me). If optional type marking on method signiture is possible on Smalltalk, it shoul开发者_C百科d be great for me.

I don't care about compiler LINT check. I'm wishing just a feature noting parameter types on the source code with regular syntax. Regular syntax or preprocessors. Please let me know anything.


No,

there is no such thing in standard Smalltalk. Quite often people choose parameter name that also hints it's type like in:

move: anDisplacementInteger


In addition to Davorin's point of documenting through comments or type-revealing parameter names, there is always the possibility of extending Compiler to support type annotation.

Efficient Multimethods in a Single Dispatch Language shows how Foote et al extended Compiler to support multimethods in Smalltalk, and uses the technique of annotating methods thusly:

ComponentPart>>
    add: aVisualComponent <BorderWrapper>
    borderedIn: aLayoutObject

In particular, the paper's technique does not enforce the annotations throughout the image, so you could annotate only your methods.


You may be interested in the Etoiles project which allows the same object to execute methods in Smalltalk, Objective-C and Objective-C++.

There will be a presentation on this at the 19th International Smalltalk Conference in Edinburgh at end-August.

0

精彩评论

暂无评论...
验证码 换一张
取 消