removed the association literal notation
This commit is contained in:
@ -460,7 +460,7 @@ class Dictionary(Set)
|
||||
* to a dictionary with the dictionary/association expression notation
|
||||
* like this:
|
||||
*
|
||||
* :{ :( 1, 20 ), :( #moo, 999) }
|
||||
* :{ 1 -> 20, #moo -> 999 }
|
||||
*
|
||||
* it must return self for the way VM works.
|
||||
*)
|
||||
@ -473,6 +473,10 @@ class Dictionary(Set)
|
||||
hv := key hash.
|
||||
index := hv rem: bs.
|
||||
|
||||
(* as long as 'assoc' supports the message 'key' and 'value'
|
||||
* this dictionary should work. there is no explicit check
|
||||
* on this protocol of key and value. *)
|
||||
|
||||
while ((ass := self.bucket at: index) notNil)
|
||||
{
|
||||
if (key = ass key)
|
||||
@ -497,7 +501,9 @@ class Dictionary(Set)
|
||||
self.tally := ntally.
|
||||
self.bucket at: index put: assoc.
|
||||
|
||||
^self. ## it must return self for the instructions generated by the compiler.
|
||||
(* it must return self for the instructions generated by the compiler.
|
||||
* otherwise, VM will break. *)
|
||||
^self.
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -240,21 +240,17 @@ class MyObject(Object)
|
||||
|
||||
(* Dictionary ???
|
||||
a := #{
|
||||
:( key, value ),
|
||||
:( key, value ),
|
||||
:( key, value ),
|
||||
:( key, value )
|
||||
key -> value ,
|
||||
key -> value ,
|
||||
key -> value ,
|
||||
key -> value
|
||||
}
|
||||
|
||||
a := :{
|
||||
:( key, value ),
|
||||
key -> value,
|
||||
}
|
||||
*)
|
||||
|
||||
|
||||
(* abc := { key, value }.
|
||||
{ key, value } dump. *)
|
||||
|
||||
a do: [ :v | v dump].
|
||||
|
||||
(*
|
||||
@ -289,20 +285,16 @@ class MyObject(Object)
|
||||
##if (false) {} else { break }.
|
||||
}.
|
||||
}.*)
|
||||
|
||||
##:() dump. ## missing association key
|
||||
##:(a+10,) dump. ## missing association value.
|
||||
##:(1,2,3) dump. ## ) expecte where , is
|
||||
##:(a+100,a*99) dump.
|
||||
##:(a+a+100,a*a*99) dump.
|
||||
|
||||
|
||||
a := :{
|
||||
:('aaa', 10),
|
||||
:('bbb', 20),
|
||||
:('bbb', 30),
|
||||
:(#bbb, 40),
|
||||
##:(5, 99),
|
||||
:('ccc', 890)
|
||||
'aaa' -> 10,
|
||||
'bbb' -> 20,
|
||||
'bbb' -> 30,
|
||||
#bbb -> 40,
|
||||
Association key: 12343 value: 129908123,
|
||||
##5 -> 99,
|
||||
'ccc' -> 890
|
||||
}.
|
||||
|
||||
(*a removeKey: 'bbb'.
|
||||
@ -315,8 +307,7 @@ class MyObject(Object)
|
||||
'------------' dump.
|
||||
].
|
||||
|
||||
|
||||
(a associationAt: :(#aaa)) dump.
|
||||
(a associationAt: (#aaa -> nil)) dump.
|
||||
(*
|
||||
while (true)
|
||||
{
|
||||
@ -326,7 +317,7 @@ class MyObject(Object)
|
||||
(1 + (if (false) {} else { break })) dump.
|
||||
}
|
||||
}*)
|
||||
|
||||
|
||||
Processor sleepFor: 20.
|
||||
}
|
||||
|
||||
|
@ -107,9 +107,6 @@ class MyObject(Object)
|
||||
'break or continue not within a loop'
|
||||
'break or continue within a block'
|
||||
'while expected'
|
||||
'missing association key'
|
||||
'missing association value'
|
||||
'missing association'
|
||||
).
|
||||
|
||||
f := Stdio open: 'generr.out' for: 'w'.
|
||||
|
Reference in New Issue
Block a user