Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal - subsection Duck Typing #196

Open
bencoman opened this issue Mar 21, 2017 · 1 comment
Open

Proposal - subsection Duck Typing #196

bencoman opened this issue Mar 21, 2017 · 1 comment

Comments

@bencoman
Copy link
Contributor

Following on from my response here...
http://forum.world.st/Question-tp4939264p4939265.html
I propose a small subsection "Duck Typing" with an example like below.
I don't see anywhere in PBE that this equivalence is explained...

On Sun, Mar 19, 2017 at 8:53 PM, Ben Coman [email protected] wrote:

In Playground, evaluate...
Integer compile: '
plusOne
^ self + 1' .

Then inspect...
#(1 2 3) collect: #plusOne.

Debug into it, to observe #value: sent to aBlock variable when it holds #plusOne
such that ByteSymbol(Symbol)>>#value: twists this into a send of
#plusOne (i.e. self) to anObject.

In general, since symbols and blocks both respond to #value:
they can be used interchangeably.

Also perhaps a small summary of this discussion...
http://forum.world.st/Smalltalk-strongly-typed-td4701894i20.html
I'd seed the thought that Smalltalk is strongly typed, while pointing out lack of consensus
but to not conflate static-typing and strongly-typed.

@bencoman
Copy link
Contributor Author

"Duck typing" subsection might fit after "High-order iterators" subsection where #collect: is first mentioned.
Or perhaps fit after "Every object is an instance of a class" subsection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant