namgk / ambienttalk

Automatically exported from code.google.com/p/ambienttalk
0 stars 0 forks source link

Keywords and Optional Varargs #20

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
We need some kind of keyworded message sends that are matched against a kind of 
‘regular 
expression’ for stuff like try-catch and when-catch, such that e.g. the 
following invocations all 
trigger the same language construct:

when: f becomes: { |v| ... }
when: f becomes: { |v| ... } due: 1000
when: f becomes: { |v| ... } catch: Exc1 using: { |e| ... } 

This could be done using optional and vararg parameters with keywords:

def when: future becomes: block due: time := default catch: @blocks {
  ...
}

This method actually has a selector when:becomes:[due:](catch:)* and regexp 
matching could be 
used to match invocation with definition.

We really need this kind of semantics if we want to make optional arguments and 
varargs work 
for keywords.

It becomes really important in the context of the object: object creation 
primitives. There are 
more than 12 of these keyworded methods because they need to fill in 
“default” arguments. The 
problem is: adding a new “property” to objects requires re-implementing all 
previous object 
creation methods to take the new default into account.

Original issue reported on code.google.com by tvcut...@gmail.com on 16 Sep 2008 at 2:06