Permalink
Browse files

use expression pattern-matching for a few macros

  • Loading branch information...
1 parent 6143453 commit 5b213e8b1e985e70f8acff0e400ae3c091bfdd79 Alex Suraci committed Mar 9, 2011
Showing with 11 additions and 10 deletions.
  1. +6 −6 kernel/concurrency.atomo
  2. +5 −4 kernel/data.atomo
View
@@ -5,9 +5,9 @@ me := Actor current
Actor <- v := send(v)
macro (receive(&body))
- { bs = body contents collect { e |
- blk = Atomo::AST::Block new(body line, [e rhs], [e lhs])
- `(e when(~(Atomo::Patterns from_node(e lhs)), &~blk))
+ { bs = body contents collect { `(~pat -> ~body) |
+ blk = Atomo::AST::Block new(body line, [pat], [body])
+ `(e when(~(Atomo::Patterns from_node(pat)), &~blk))
}
branches = Atomo::AST::Block new(body line, bs, ['e])
@@ -16,9 +16,9 @@ macro (receive(&body))
} call
macro (receive: body after: timeout)
- { bs = body contents collect { e |
- blk = Atomo::AST::Block new(body line, [e rhs], [e lhs])
- `(e when(~(Atomo::Patterns from_node(e lhs)), &~blk))
+ { bs = body contents collect { `(~pat -> ~body) |
+ blk = Atomo::AST::Block new(body line, [pat], [body])
+ `(e when(~(Atomo::Patterns from_node(pat)), &~blk))
}
bs << `(e after(~(timeout lhs), &{ ~(timeout rhs) }))
View
@@ -16,10 +16,11 @@ macro ($(x: 'exception))
macro ($(x: Variable))
Atomo::AST::GlobalVariable new(x line, x name)
-macro (class(pair: BinarySend, &body))
- if: (pair lhs == 'self)
- then: { Atomo::AST::Metaclass new(pair line, pair rhs, body body) }
- else: { Atomo::AST::Class new(pair line, pair lhs, body body, pair rhs) }
+macro (class(`(<< ~obj), &body))
+ Atomo::AST::Metaclass new(obj line, obj, body body)
+
+macro (class(`(~name < ~super), &body))
+ Atomo::AST::Class new(name line, name, body body, super)
macro (class(name, &body))
Atomo::AST::Class new(name line, name, body body)

0 comments on commit 5b213e8

Please sign in to comment.