Permalink
Browse files

Change "where" to "when".

  • Loading branch information...
1 parent aad2db2 commit 5740160fbc3b50a93ba11ea237c8f4bdd59ba6b9 nineties committed Feb 20, 2013
@@ -28,15 +28,15 @@ module HyperLisp {
# Create sexp which represents the position of metaliteral X
point: (X, X) -> one
| (Y@Meta, X) -> zero
- | (z, X) where z == zero -> zero
+ | (z, X) when z == zero -> zero
| (Eq{x, y}, X) -> {
px: point(x, X)
py: point(y, X)
if (px == zero) return py
if (py == zero) return px
throw `DuplicatedParameter{!X}
}
- | (x, X) where head(x.car) == \Whole -> { # [.x] or (.x)
+ | (x, X) when head(x.car) == \Whole -> { # [.x] or (.x)
point(x.car[0], X)
}
| (x, X) -> { # [x,y,z] or (x,y,z)
@@ -48,13 +48,13 @@ module HyperLisp {
}
compile_as_sexp
- : (p, z) where z == zero -> (zero, zero)
+ : (p, z) when z == zero -> (zero, zero)
| (p, X@Meta) -> {
pos: point(p, X)
if (pos == zero) return (zero, X)
(snoc(pos, zero), zero)
}
- | (p, x) where atom(x) -> {
+ | (p, x) when atom(x) -> {
(p1, b1): compile_as_sexp(p, x.car)
(p2, b2): compile_as_sexp(p, x.cdr)
(cons(p1, p2), snoc(b1, b2))
@@ -65,72 +65,72 @@ module HyperLisp {
(cons(p1, p2), cons(b1, b2))
}
- compile_arg: (p, x) where p == zero -> zero
- | (p, x) where p == one -> x
+ compile_arg: (p, x) when p == zero -> zero
+ | (p, x) when p == one -> x
| (p, x) -> {
p1: compile_arg(p.car, `(!x).car)
if (p1 != zero) return p1
return compile_arg(p.cdr, `(!x).cdr)
}
compile_eval
- : (p, x) where atom(p) -> compile_arg(p.car, \x)
+ : (p, x) when atom(p) -> compile_arg(p.car, \x)
| (p, x@Meta) -> `\!x[0]
| (p, x@Symbol) -> `\!x
- | (p, x) where x.car == \cond
+ | (p, x) when x.car == \cond
-> compile_cond(p.cdr, x.cdr)
| (p, x) -> compile_apply(p, x, atom(x))
compile_evlis
- : (p, x) where atom(p) -> compile_arg(p.car, \x)
- | (p, x) where x == zero -> `\!zero
+ : (p, x) when atom(p) -> compile_arg(p.car, \x)
+ | (p, x) when x == zero -> `\!zero
| (p, x) -> `cons(!compile_eval(p.car, x.car),
!compile_evlis(p.cdr, x.cdr))
compile_apply(p, x, \true):
`(!compile_obj(p.car, x.car))(!compile_obj(p.cdr, x.cdr))
compile_apply(p, x, \false):
`(!compile_obj(p.car, x.car))(!compile_evlis(p.cdr, x.cdr))
- compile_apply(p, x, f) where x.car == \cons: {
+ compile_apply(p, x, f) when x.car == \cons: {
a: compile_(p.cdr.car, x.cdr.car, f)
b: compile_(p.cdr.cdr.car, x.cdr.cdr.car, f)
`cons(!a,!b)
}
- compile_apply(p, x, f) where x.car == \snoc: {
+ compile_apply(p, x, f) when x.car == \snoc: {
a: compile_(p.cdr.car, x.cdr.car, f)
b: compile_(p.cdr.cdr.car, x.cdr.cdr.car, f)
`snoc(!a, !b)
}
- compile_apply(p, x, f) where x.car == \car: {
+ compile_apply(p, x, f) when x.car == \car: {
a: compile_(p.cdr.car, x.cdr.car, f)
`at(!a, 0)
}
- compile_apply(p, x, f) where x.car == \cdr: {
+ compile_apply(p, x, f) when x.car == \cdr: {
a: compile_(p.cdr.car, x.cdr.car, f)
`at(!a, 1)
}
- compile_apply(p, x, f) where x.car == \eq: {
+ compile_apply(p, x, f) when x.car == \eq: {
a: compile_(p.cdr.car, x.cdr.car, f)
b: compile_(p.cdr.cdr.car, x.cdr.cdr.car, f)
`((!a == !b) ? \!one : \!zero)
}
- compile_apply(p, x, f) where x.car == \null: {
+ compile_apply(p, x, f) when x.car == \null: {
a: compile_(p.cdr.car, x.cdr.car, f)
`((!a == !zero) ? \!one : \!zero)
}
- compile_apply(p, x, f) where x.car == \atom: {
+ compile_apply(p, x, f) when x.car == \atom: {
a: compile_(p.cdr.car, x.cdr.car, f)
`(atom(!a) ? \!one : \!zero)
}
- compile_apply(p, x, f) where x.car == \puts: {
+ compile_apply(p, x, f) when x.car == \puts: {
a: compile_(p.cdr.car, x.cdr.car, f)
`puts(!a)
}
- compile_apply(p, x, f) where x.car == \exit:
+ compile_apply(p, x, f) when x.car == \exit:
exit(0)
- compile_apply(p, x, f) where x.car == one:
+ compile_apply(p, x, f) when x.car == one:
compile_(p.cdr.car, x.cdr.car, f)
- compile_apply(p, x, f) where x.car == zero: `\!zero
+ compile_apply(p, x, f) when x.car == zero: `\!zero
compile_cond(p, x): {
condition: compile_condition(p.car.car, x.car.car)
@@ -141,31 +141,31 @@ module HyperLisp {
else
`IfElse{!condition, !body1, !body2}
}
- compile_cond(p, x) where x == zero: `\!zero
+ compile_cond(p, x) when x == zero: `\!zero
compile_condition(p, x): `atom(!compile_eval(p, x))
- compile_condition(p, x) where x.car == \eq: {
+ compile_condition(p, x) when x.car == \eq: {
a: compile_(p.cdr.car, x.cdr.car, atom(x))
b: compile_(p.cdr.cdr.car, x.cdr.cdr.car, atom(x))
`(!a == !b)
}
- compile_condition(p, x) where x.car == \null: {
+ compile_condition(p, x) when x.car == \null: {
a: compile_(p.cdr.car, x.cdr.car, atom(x))
`(!a == \!zero)
}
- compile_condition(p, x) where x.car == \atom: {
+ compile_condition(p, x) when x.car == \atom: {
a: compile_(p.cdr.car, x.cdr.car, atom(x))
`atom(!a)
}
- compile_condition(p, x) where x == snoc(one, snoc(one, zero)): \true
+ compile_condition(p, x) when x == snoc(one, snoc(one, zero)): \true
compile_(p, x, \true): compile_obj(p, x)
compile_(p, x, \false): compile_eval(p, x)
compile_obj
- : (p, x) where atom(p) -> compile_arg(p.car, \x)
+ : (p, x) when atom(p) -> compile_arg(p.car, \x)
| (p, x@Meta) -> rename(x[0])
| (p, x@Symbol) -> rename(x)
- | (p, x) where x == zero -> `\!zero
+ | (p, x) when x == zero -> `\!zero
| (p, x@Cons) -> {
a: compile_obj(p.car, x.car)
b: compile_obj(p.cdr, x.cdr)
@@ -199,8 +199,8 @@ module HyperLisp {
cons_list([\label, p, b])
# compile label-expression as a native function of Amber.
- replace_label: (n, p, b) where p == zero -> b
- | (n, p, b) where atom(p) -> n
+ replace_label: (n, p, b) when p == zero -> b
+ | (n, p, b) when atom(p) -> n
| (n, p, b@Cons)
-> cons(replace_label(n, p.car, b.car),
replace_label(n, p.cdr, b.cdr))
@@ -235,7 +235,7 @@ module HyperLisp {
amber::define_global_variable(rename(sym), fun)
sym
}
- eval_(x) where x.car == \Meta{Delta}: eval_define(x)
+ eval_(x) when x.car == \Meta{Delta}: eval_define(x)
eval_(x@Meta): throw `UndefinedMetaLiteral{!x}
# lambda-abstraction and label-expression is just a syntax sugar.
@@ -244,9 +244,9 @@ module HyperLisp {
hl_expr_macro ::= old_hl_expr { macro($0) }
ReplaceSyntax{hl_expr, hl_expr_macro}
- macro: x@Cons where x.car == \Meta{Lambda} -> compile_lambda(x)
- | x@Cons where x.car == \Meta{Label} -> compile_label(x)
- | x where x == zero -> zero
+ macro: x@Cons when x.car == \Meta{Lambda} -> compile_lambda(x)
+ | x@Cons when x.car == \Meta{Label} -> compile_label(x)
+ | x when x == zero -> zero
| x@Cons -> cons(macro(x.car), macro(x.cdr))
| x@Snoc -> snoc(macro(x.car), macro(x.cdr))
| x -> x
@@ -29,15 +29,15 @@ module HyperLisp {
is_char(sexp): char_tbl[sexp] != undef
- #pprint(io, x) where is_char(x):
+ #pprint(io, x) when is_char(x):
# pprint(io, char_tbl[x])
# Extend Recognizer
atom(x@Symbol): true
# Extend Constructors
- make_snoc(x, y) where is_char(x) and y == zero : char_tbl[x].to_sym
- make_snoc(x, y@Symbol) where is_char(x) : (char_tbl[x] + y).to_sym
+ make_snoc(x, y) when is_char(x) and y == zero : char_tbl[x].to_sym
+ make_snoc(x, y@Symbol) when is_char(x) : (char_tbl[x] + y).to_sym
# Extend Selectors
car(x@Symbol): encode_byte( x.to_s[0].code )
@@ -39,28 +39,28 @@ module HyperLisp {
# Pretty printing
is_cons_list
- : x where x == zero -> true
+ : x when x == zero -> true
| e@Cons -> is_cons_list(e.cdr)
| _ -> false
is_snoc_list
- : x where x == zero -> true
+ : x when x == zero -> true
| e@Snoc -> is_snoc_list(e.cdr)
| _ -> false
pprint
- : (io, x) where x == zero -> print(io, "0")
- | (io, x) where x == one -> print(io, "1")
- | (io, e@Cons) where is_cons_list(e)
+ : (io, x) when x == zero -> print(io, "0")
+ | (io, x) when x == one -> print(io, "1")
+ | (io, e@Cons) when is_cons_list(e)
-> print(io, "("); pprint_cons_list(io, e); print(io, ")")
- | (io, e@Snoc) where is_snoc_list(e)
+ | (io, e@Snoc) when is_snoc_list(e)
-> print(io, "["); pprint_cons_list(io, e); print(io, "]")
| (io, e@Cons) -> printf(io, "(%p . %p)", e.car, e.cdr)
| (io, e@Snoc) -> printf(io, "[%p . %p]", e.car, e.cdr)
pprint_cons_list
- : (io, x) where x == zero -> nil
- | (io, e@Cons) where e.cdr == zero -> pprint(io, e.car)
- | (io, e@Snoc) where e.cdr == zero -> pprint(io, e.car)
+ : (io, x) when x == zero -> nil
+ | (io, e@Cons) when e.cdr == zero -> pprint(io, e.car)
+ | (io, e@Snoc) when e.cdr == zero -> pprint(io, e.car)
| (io, e@Cons)
-> pprint(io, e.car); print(io, ", "); pprint_cons_list(io, e.cdr)
| (io, e@Snoc)
View
@@ -25,7 +25,7 @@ ReplaceSyntax{comment, shell_style_comment}
# [^..] : noneof
## Amber's unique syntax elements
-# aligned(p) : sequence of p where every p has same indentation
+# aligned(p) : sequence of p when every p has same indentation
# delimited(p, d) : sequence of p delimited by d
# delimited1(p, d) : sequence of p delimited by d (one or many)
# delimited2(p, d) : sequence of p delimited by d (two or many)
@@ -294,12 +294,12 @@ ternary_expr
guard_expr ::= ternary_expr
arguments
- ::= "(" delimited(pattern, ",") ")" "where" guard_expr
- { `Where{!node1, !node4} }
+ ::= "(" delimited(pattern, ",") ")" "when" guard_expr
+ { `When{!node1, !node4} }
| "(" delimited(pattern, ",") ")"
{ node1 }
- | !"{" pattern "where" guard_expr
- { `Where{List{!node1}, !node3} }
+ | !"{" pattern "when" guard_expr
+ { `When{List{!node1}, !node3} }
| !"{" pattern
{ List{node1} }
@@ -381,7 +381,7 @@ statement
{ `DefineFunction{rewrite, Lambda{!node0, !node2}} }
## Reserved Keywords
-ReserveSymbol{not, and, or, where, open, if, else, case, of,
+ReserveSymbol{not, and, or, when, open, if, else, case, of,
while, for, reverse_for, in, continue, break, return,
throw, try, catch, seq, scope
}
View
@@ -44,9 +44,9 @@ module HIL {
\ModAssign => \FVmodasgn
]
- typing_assign(x, IVector{dim1}, e, IVector{dim2}, op) where dim1 == dim2 :
+ typing_assign(x, IVector{dim1}, e, IVector{dim2}, op) when dim1 == dim2 :
MakeObject{iasgnop[op], [dim1, x, e]}
- typing_assign(x, FVector{dim1}, e, FVector{dim2}, op) where dim1 == dim2 :
+ typing_assign(x, FVector{dim1}, e, FVector{dim2}, op) when dim1 == dim2 :
MakeObject{fasgnop[op], [dim1, x, e]}
typing_unary(e, IVector{dim}, \UnaryMinus):
@@ -59,13 +59,13 @@ module HIL {
typing_unary(e, FVector{dim}, \Absolute):
(\Float, `FVabs{!dim, !e})
- typing_binary(v1, FVector{dim1}, v2, FVector{dim2}, \Add) where dim1 == dim2:
+ typing_binary(v1, FVector{dim1}, v2, FVector{dim2}, \Add) when dim1 == dim2:
(`FVector{!dim1}, `FVadd{!dim1, !v1, !v2})
- typing_binary(v1, FVector{dim1}, v2, FVector{dim2}, \Sub) where dim1 == dim2:
+ typing_binary(v1, FVector{dim1}, v2, FVector{dim2}, \Sub) when dim1 == dim2:
(`FVector{!dim1}, `FVsub{!dim1, !v1, !v2})
- typing_binary(v1, FVector{dim1}, v2, FVector{dim2}, \Mul) where dim1 == dim2:
+ typing_binary(v1, FVector{dim1}, v2, FVector{dim2}, \Mul) when dim1 == dim2:
(`FVector{!dim1}, `FVmul{!dim1, !v1, !v2})
- typing_binary(v1, FVector{dim1}, v2, FVector{dim2}, \Div) where dim1 == dim2:
+ typing_binary(v1, FVector{dim1}, v2, FVector{dim2}, \Div) when dim1 == dim2:
(`FVector{!dim1}, `FVdiv{!dim1, !v1, !v2})
typing_binary(v, FVector{dim}, r, Float, \Mul):
View
@@ -2,7 +2,7 @@
; rowl - 1st generation
; Copyright (C) 2010 nineties
;
-; $Id: rowl1-compile.rlc 2013-02-19 22:53:25 nineties $
+; $Id: rowl1-compile.rlc 2013-02-20 16:57:12 nineties $
;
(import "rlvm-compile")
@@ -78,7 +78,7 @@
))
(fun delete_args (node fv) (
- (if (== (node_bhead node) Where)
+ (if (== (node_bhead node) When)
(return (iter_args list_delete (node_arg node 0) fv 0))
(return (iter_args list_delete node fv 0))
)
@@ -89,7 +89,7 @@
))
(fun collect_args (args) (
- (if (== (node_bhead args) Where)
+ (if (== (node_bhead args) When)
(return (iter_args add_var (node_arg args 0) 0 0))
(return (iter_args add_var args 0 0))
)
@@ -128,7 +128,7 @@
(if (== hd Lambda) (do
(= fv (fv_iter mod (node_arg expr 1) 0 fv))
(var arg (node_arg expr 0))
- (if (== (node_bhead arg) Where)
+ (if (== (node_bhead arg) When)
(= fv (fv_iter mod (node_arg arg 1) 0 fv))
)
(return (delete_args (node_arg expr 0) fv))
@@ -162,7 +162,7 @@
; This routine also translates
; f(... x ... x ...) : body
; to
-; f(... x ... y ...) where x==y : body
+; f(... x ... y ...) when x==y : body
(extern fun list_to_table)
(fun alpha_args_iter (tbl chk rep expr level) (
(if (is_symbol expr) (do
@@ -233,7 +233,7 @@
(fun alpha_args (tbl args) (
(var chk (struct 1 0))
(var rep (struct 1 0))
- (if (== (node_bhead args) Where)
+ (if (== (node_bhead args) When)
(do
(node_arg_set args 0
(alpha_args_iter tbl chk rep (node_arg args 0) 0))
@@ -246,7 +246,7 @@
(var guard (setup_guard rep @C_NIL))
(if (== guard @C_NIL)
(return args)
- (return (make_object2 Where args guard))
+ (return (make_object2 When args guard))
)
))
))
@@ -481,7 +481,7 @@
))
(if (== hd Lambda) (do
(var lhs (node_arg expr 0))
- (if (== (node_bhead lhs) Where)
+ (if (== (node_bhead lhs) When)
(node_arg_set lhs 1 (subst_clsvars tbl cls (node_arg lhs 1)))
)
(node_arg_set expr 1 (subst_clsvars tbl cls (node_arg expr 1)))
@@ -1789,7 +1789,7 @@
(var hd (node_bhead lhs))
(if (== hd List)
(compile_lambda_main asm mod lhs body noguard cls)
- (if (== hd Where)
+ (if (== hd When)
(do
(var guard (node_arg lhs 1))
(var args (node_arg lhs 0))
Oops, something went wrong.

0 comments on commit 5740160

Please sign in to comment.