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

generalized blocks #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion Smalltalk/Block.som
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,23 @@ Block = (
"For the creation of Block instances, see Universe_new_block()."

"Evaluation"
value = primitive
value = (
^self valueWithArguments: (Array new: 1)
)

value: arg = (
^self valueWithArguments: (Array with: arg)
)

value: arg1 with: arg2 = (
^self valueWithArguments: (Array with: arg1 with: arg2)
)

value: arg1 with: arg2 with: arg3 = (
^self valueWithArguments: (Array with: arg1 with: arg2 with: arg3)
)

valueWithArguments: args = primitive

"Looping"
whileFalse: block = (
Expand All @@ -50,6 +66,14 @@ Block = (
ifTrue: [self value]
ifFalse: [self value: anArg]
)

ensure: aBlock = (
"Implemented for FileSystem support. It still does not comply with ensure behavior when the block fails"
| returnValue |
returnValue := self value.
aBlock value.
^returnValue
)

" Petit Parser"
asParser = (^ PPPluggableParser on: self)
Expand Down
39 changes: 0 additions & 39 deletions Smalltalk/Block1.som

This file was deleted.

46 changes: 0 additions & 46 deletions Smalltalk/Block2.som

This file was deleted.

39 changes: 0 additions & 39 deletions Smalltalk/Block3.som

This file was deleted.

42 changes: 0 additions & 42 deletions Smalltalk/Block4.som

This file was deleted.

1 change: 1 addition & 0 deletions TestSuite/BasicInterpreterTests/Blocks.som
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ THE SOFTWARE.
Blocks = (

----
argWithArguments = ( ^ [:a | a] valueWithArguments: (Array with: 1 with: 2) )

arg1 = ( ^ [:a | a - 1] value: 43 )

Expand Down