Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Map -> Atomy::Map, a subclass of Hamster::Hash; rename hashes kernel …

…to maps
  • Loading branch information...
commit 64327af45c3e7bfd4faed71f8075ffea408f2c96 1 parent 637fa98
Alex Suraci authored
View
2  kernel/boot.ay
@@ -67,7 +67,7 @@ macro(_FILE): File new(line)
macro(import(name)): `(Atomy import(~name, "load" to-sym))
"operators define cosmetics data comparison dynamic control-flow patterns
-precision node data-delta particles hashes block documentation namespaces doc
+precision node data-delta particles maps block documentation namespaces doc
pretty errors format concurrency io condition therie repl" split each [k]:
puts("loading " + k)
import(File expand-path("../", _FILE) + "/" + k)
View
1  kernel/data.ay
@@ -51,7 +51,6 @@ macro(x for(e) in(c) if(t)):
`(~c collect [~e] { ~x } select [~e] { ~t })
List = Hamster::List
-Map = Hamster::Hash
List inject-right(i = _undefined, &block) :=
reverse inject(i) [x, y]: block [y, x]
View
21 kernel/hashes.ay → kernel/maps.ay
@@ -7,10 +7,10 @@ macro(#(l: List)):
pairs = pairs-from(l elements)
keys = pairs collect [[k, _]]: `#~key-name(k)
values = pairs collect [[_, v]]: v
- Atomy::AST::Hash new(line, keys, values)
+ Atomy::AST::Map new(line, keys, values)
-class(Atomy::AST::Hash < Atomy::AST::Node):
+class(Atomy::AST::Map < Atomy::AST::Node):
children([#keys], [#values])
generate
@@ -18,7 +18,8 @@ class(Atomy::AST::Hash < Atomy::AST::Node):
pos(g)
g push-cpath-top
- g find-const(#Hamster)
+ g find-const(#Atomy)
+ g find-const(#Map)
g push-cpath-top
g find-const(#Hash)
@@ -32,4 +33,16 @@ class(Atomy::AST::Hash < Atomy::AST::Node):
g send("[]=" to-sym, 2)
g pop
- g send(#hash, 1)
+ g send(#create, 1)
+
+class(Atomy::Map < Hamster::Hash):
+ class(<< self):
+ create(pairs = ::Hash new, &blk) := do:
+ base =
+ if(blk)
+ then: Map new(&blk)
+ else: Atomy::EmptyMap
+
+ pairs reduce(base) [hash, pair]: hash put(pair first, pair last)
+
+Atomy::EmptyMap = Atomy::Map new
View
2  kernel/pretty.ay
@@ -110,7 +110,7 @@ Hash pretty := doc:
to-a collect [[k, v]]:
k unamb <+> text("->") <+> v unamb
-Map pretty := doc:
+Atomy::Map pretty := doc:
text("#") <>
brackets $:
comma separate $:
Please sign in to comment.
Something went wrong with that request. Please try again.