Skip to content

Commit 99875fc

Browse files
authored
Merge pull request #124 from aya-lang/alt-dict-syntax
Change dict syntax from `{, ...}` to `:{...}`
2 parents 9912b73 + ec73a33 commit 99875fc

File tree

126 files changed

+999
-905
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+999
-905
lines changed

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ Use aya's `turtle` and `color` modules to draw a pattern
195195
import ::turtle
196196
import ::color
197197
198-
{,
198+
:{
199199
400:width;
200200
400:height;
201201
color.colors.darkblue :bg_color;
@@ -225,7 +225,7 @@ import ::plot
225225
import ::stats
226226
227227
"Downloading file..." :P
228-
{,
228+
:{
229229
"https://raw.githubusercontent.com/vincentarelbundock/Rdatasets/master/csv/datasets/LakeHuron.csv":filename
230230
1:csvindex
231231
}
@@ -238,8 +238,8 @@ df.["value"] :y;
238238
x y stats.regression :r;
239239
240240
plot.plot! :plt;
241-
x y {, "Water Level":label} plt.plot
242-
x {r} {, "Trend":label} plt.plot
241+
x y :{ "Water Level":label} plt.plot
242+
x {r} :{ "Trend":label} plt.plot
243243
244244
"Water Level of Lake Huron" plt.:title;
245245
[575 583] plt.y.:lim;

ayarc.aya

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
:{sys.ad} "base/__aya__.aya" + :F
1+
:(sys.ad) "base/__aya__.aya" + :F

base/__aya__.aya

+23-23
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@
77
.# NOTE: 12 letter variables ending in the letter 'z' are reserved for use in
88
.# standard library. Such variables are used below.
99

10-
{:{sys.ad} "test/test.aya" + :F}:tt;
10+
{:(sys.ad) "test/test.aya" + :F}:tt;
1111

1212
.# Global __aya__ table
13-
{,
13+
:{
1414

15-
{,}:interpreter;
15+
:{}:interpreter;
1616

1717
.# If set to 1, all breakpoints will be ignored
1818
.#? __aya__.ignore_breakpoints\n if true, skip all breakpoints
1919
0 :ignore_breakpoints;
2020

2121
}:__aya__;
2222

23-
{,
24-
{,
23+
:{
24+
:{
2525
::__nil :__type__;
2626
"nil" :__str__;
2727
"nil" :__repr__'
@@ -41,7 +41,7 @@
4141
.#? bp\n set a breakpoint
4242
{ : __aya__^,
4343
__aya__.ignore_breakpoints ! {
44-
:{debug.pause}
44+
:(debug.pause)
4545
} ?
4646
}:bp;
4747

@@ -66,7 +66,7 @@
6666
.# -------
6767

6868
{name,
69-
[:{sys.ad} :9s "examples" :9s name ".aya"] W :F
69+
[:(sys.ad) :9s "examples" :9s name ".aya"] W :F
7070
}:example;
7171

7272

@@ -91,9 +91,9 @@
9191
}
9292
)
9393

94-
aya> f {,} ::foo {"a"}
94+
aya> f :{} ::foo {"a"}
9595
with_mod!
96-
[ {"a"} ::foo {,} ]
96+
[ {"a"} ::foo :{} ]
9797

9898
aya> f ::foo {"a"}
9999
no mod!
@@ -109,7 +109,7 @@
109109
_no_mod:no_mod;
110110

111111
.# Store functions on stack so they can be retrieved later
112-
{,
112+
:{
113113
no_mod.` :no_mod
114114
with_mod.` :with_mod
115115
}
@@ -119,8 +119,8 @@
119119
.# aya> {mod name block, mod ::_fn =! {;} ? [mod name block.`]} :f
120120

121121
.# Jump ahead 3 items
122-
.# aya> (```(\:&:T ::sym=! {\`}{\}.? f) ::_fn) {,} ::foo {+}
123-
.# [ {,} ::foo {+} ]
122+
.# aya> (```(\:&:T ::sym=! {\`}{\}.? f) ::_fn) :{} ::foo {+}
123+
.# [ :{} ::foo {+} ]
124124

125125
.# Jump ahead 2 items
126126
.# aya> (```(\:&:T ::sym=! {\`}{\}.? f) ::_fn) ::foo {+}
@@ -156,7 +156,7 @@
156156
}
157157

158158
.# Use constant substitution until var^ syntax is introduced
159-
{, no_mod.`:_no_mod with_mod.`:_with_mod} .+
159+
:{ no_mod.`:_no_mod with_mod.`:_with_mod} .+
160160

161161
} __aya__.:opt_mod;
162162

@@ -178,7 +178,7 @@
178178

179179
Define a function in a module scope:
180180

181-
aya> {,}:math;
181+
aya> :{}:math;
182182
aya> def math::sq {2^}
183183
aya> 5 math.sq
184184
25
@@ -194,7 +194,7 @@
194194

195195
Define a function in a submodule:
196196

197-
aya> {, {,}:stats; }:math;
197+
aya> :{ :{}:stats; }:math;
198198
aya> def (math.stats)::mean {.E\W\/}
199199
aya> [1 2 3 4] math.stats.mean
200200
2.5
@@ -218,9 +218,9 @@
218218
.#
219219
.# `objcet`: Base object for class and struct
220220
.#
221-
{,
221+
:{
222222
{meta : instance,
223-
{,
223+
:{
224224
meta :__meta__;
225225
1 :__pushself__;
226226
} :instance;
@@ -250,7 +250,7 @@
250250
.#
251251

252252
{type::sym super,
253-
{,
253+
:{
254254
super:__meta__;
255255
type:__type__;
256256
.# copy new from super directly
@@ -297,7 +297,7 @@ __aya__.extend.` :extend;
297297
num_members :A
298298
.# and assign them to self
299299
members {self :D} .&;
300-
} {,
300+
} :{
301301
members__ E :num_members;
302302
members__ :members;
303303
} .+ cls__.:__init__;
@@ -311,7 +311,7 @@ __aya__.extend.` :extend;
311311
" ) " +
312312
name +
313313
"!"+
314-
} {,
314+
} :{
315315
type__ :C :name;
316316
members__ :members;
317317
} .+ cls__.:__str__;
@@ -332,14 +332,14 @@ __aya__.extend.` :extend;
332332

333333
.#? module sym\n declare a new module
334334
{name::sym,
335-
{,
335+
:{
336336
name :__modname__;
337337

338338
{meta,
339339
"Cannot create new instance of module $(meta.__modname__:C)" .D
340340
} :__new__;
341341

342-
{,
342+
:{
343343
::module :__type__;
344344
"(module $name)":__repr__;
345345
}:__meta__;
@@ -448,5 +448,5 @@ __aya__.extend.` :extend;
448448

449449
] :# {f,
450450
.# "Loading base/$f..." :P
451-
load ([:{sys.ad} :9s "base/$f"]W)
451+
load ([:(sys.ad) :9s "base/$f"]W)
452452
};

base/block.aya

+2-18
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{,
1+
:{
22

33
.# Functional Operations
44
.########################
@@ -60,7 +60,7 @@
6060
.}
6161
{(1 hold)({:d__,
6262
.# Create a dictionary of all values given by the list
63-
{,}:d__;
63+
:{}:d__;
6464
:#{$~\d__:D;};
6565
.# Substitute the values from the dictionary into the block
6666
d__ .+
@@ -72,22 +72,6 @@
7272
.# Utility Functions
7373
.#####################
7474

75-
76-
.# ::list _capture_vars\n given a list of symbols, return a dict with each symbol and it's assignment
77-
.{ Example:
78-
aya> {1 +}:a 2:b
79-
{1 +} 2
80-
aya> [::a ::b].capture_vars
81-
{,
82-
{1 +}:a;
83-
2:b;
84-
}
85-
aya> [::a ::b ::c].capture_vars
86-
ERROR: Variable c not found
87-
.}
88-
{ {1, :# {$~\:=} } }:_capture_vars;
89-
90-
9175
.#? ::block .op\n return the block (allows use of (::sym or ::block) .op without type checking
9276
{}:op;
9377

base/char.aya

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
.# Metatable definition for the built-in `char` type
44

5-
{,
5+
:{
66
.#? C.islower\n tests if a character is lowercase
77
{$ 'a :> \ 'z :< &}:islower;
88

base/importlib.aya

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ def importlib::_log_debug {:importlib^,
66
importlib._debug {"importlib: " \+ :P} {;} .?
77
}
88

9-
def importlib::aya_dir :{sys.ad}
9+
def importlib::aya_dir :(sys.ad)
1010

1111
.# Dictionary of files which have been imported
12-
def importlib::imported {,}
12+
def importlib::imported :{}
1313

1414
def importlib::path [
1515
importlib.aya_dir "std" :9s + + .# <aya>/base
@@ -18,7 +18,7 @@ def importlib::path [
1818
.# Return the path with the current directory at the bottom
1919
def importlib::get_path { : importlib^ ,
2020
importlib.path
21-
:{sys.wd}
21+
:(sys.wd)
2222
J
2323
}
2424

@@ -34,7 +34,7 @@ def importlib::load_file {filename : importlib^,
3434
{ .# try
3535
"Attempting to open file $filename..." importlib._log_debug
3636
.# Load the file into a dict scope
37-
{,
37+
:{
3838
.# If __main__ exists and is 0, `main` will discard its block
3939
.# Otherwise it will execute it
4040
0:__main__;
@@ -138,7 +138,7 @@ def importlib::from_file {filepath : importlib^ all_possible mod,
138138

139139
importlib.get_path :# { filepath + } :~ :all_possible
140140
.# Get only files that exist
141-
{ :{sys.file_exists} } I
141+
{ :(sys.file_exists) } I
142142
.# If the lists is empty, throw an error
143143
.E 0 = {"Import Error: Unable to find any of the following files: $all_possible" .D} ?
144144

@@ -216,7 +216,7 @@ def importlib::export {vars : importlib^,
216216
def importlib::from {mod_sym import_vars : meta_mod importlib^,
217217
"$mod_sym $import_vars importlib.from" importlib._log_debug
218218
"from: Capturing all imported vars..." importlib._log_debug
219-
{,
219+
:{
220220
mod_sym importlib.import
221221
}:meta_mod;
222222

@@ -245,7 +245,7 @@ importlib __aya__.:importlib;
245245
.# If provided a 0 (for example from `from` keyword), do nothing
246246
{(1 hold)(:& 0= {;} {__aya__.importlib.import} .?)}:import;
247247

248-
{: importlib^ , {,} importlib.:imported; } :reimport;
248+
{: importlib^ , :{} importlib.:imported; } :reimport;
249249

250250
{(1 hold)(__aya__.importlib.export)}:export;
251251
{1:__export__;} :exportall;

base/list.aya

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
.# Metatable definition for the built-in `list` type
44

5-
{,
5+
:{
66
.# Querying
77
.###############
88

@@ -152,7 +152,7 @@
152152

153153
.#? ::list.dict_flatten\n given a list of dicts, flatten the into a single dict
154154
{
155-
{,}\J{.+}%
155+
:{}\J{.+}%
156156
}:dict_flatten;
157157

158158

base/num.aya

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
.# Metatable definition for the built-in `num` type
44

5-
{,
5+
:{
66

77
.#? ::num .digits\n convert a number into a list of digits
88
{

base/str.aya

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
.# string.aya
44
.# Defines functions for working with strings and regular expressions
55

6-
{,
6+
:{
77
.# Import list variables
88
[].M W
99

base/sym.aya

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
.# Metatable definition for the built-in `sym` type
44

5-
{,
5+
:{
66
.{? ::sym .op
77

88
Return a block containing the operator
@@ -24,7 +24,7 @@
2424
}:op;
2525

2626
.# Get a dict of all operator/symbol pairs
27-
{,
27+
:{
2828
"overloadable" M? :# {
2929
.# Get <name> <op> as strings
3030
:& "overloadable:.*$" & .[0] " " S .[-1] \ " " S .[0]
@@ -54,7 +54,7 @@
5454
::__radd__
5555
.}
5656

57-
{,
57+
:{
5858
.# Get the overload list for all ops
5959
::ops Ma :#{.overload}
6060
.# Get all ops with non-zero length overloads

base/test.aya

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
.# test.aya
44
.# Defines an interface for testing aya code
55

6-
{, } :test;
6+
:{ } :test;
77

88
.# New simpler test function
99
{blk,

examples/ayarc_eclipse.aya

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
.# cp examples/ayarc_eclipse.aya target/classes/ayarc.aya
66

77
.# The current working directory, split on path separator
8-
:{sys.wd} '/ S
8+
:(sys.wd) '/ S
99
.# Pop 2 dirs
1010
{B ;} 2 %
1111
.# Re-assemble the path
1212
#"/"+ W
1313
.# Set as current dir and aya dir
14-
$ :{sys.cd} :{sys.set_ad}
14+
$ :(sys.cd) :(sys.set_ad)
1515

1616
.# Load ayarc from the normal place
17-
:{sys.wd} "ayarc.aya" + :F
17+
:(sys.wd) "ayarc.aya" + :F

0 commit comments

Comments
 (0)