added the 'fun' symbol as an alias to 'lamba'
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
hyung-hwan 2023-11-14 12:20:47 +09:00
parent 65937937fb
commit 4f8e7ae76e
3 changed files with 21 additions and 13 deletions

View File

@ -48,6 +48,7 @@ static struct
{ 2, { 'd','o' }, HCL_SYNCODE_DO, HCL_OFFSETOF(hcl_t,_do) }, { 2, { 'd','o' }, HCL_SYNCODE_DO, HCL_OFFSETOF(hcl_t,_do) },
{ 4, { 'e','l','i','f' }, HCL_SYNCODE_ELIF, HCL_OFFSETOF(hcl_t,_elif) }, { 4, { 'e','l','i','f' }, HCL_SYNCODE_ELIF, HCL_OFFSETOF(hcl_t,_elif) },
{ 4, { 'e','l','s','e' }, HCL_SYNCODE_ELSE, HCL_OFFSETOF(hcl_t,_else) }, { 4, { 'e','l','s','e' }, HCL_SYNCODE_ELSE, HCL_OFFSETOF(hcl_t,_else) },
{ 3, { 'f','u','n' }, HCL_SYNCODE_LAMBDA, HCL_OFFSETOF(hcl_t,_fun) }, /* same syncode as lambda */
{ 2, { 'i','f' }, HCL_SYNCODE_IF, HCL_OFFSETOF(hcl_t,_if) }, { 2, { 'i','f' }, HCL_SYNCODE_IF, HCL_OFFSETOF(hcl_t,_if) },
{ 6, { 'l','a','m','b','d','a' }, HCL_SYNCODE_LAMBDA, HCL_OFFSETOF(hcl_t,_lambda) }, { 6, { 'l','a','m','b','d','a' }, HCL_SYNCODE_LAMBDA, HCL_OFFSETOF(hcl_t,_lambda) },
{ 2, { 'o','r' }, HCL_SYNCODE_OR, HCL_OFFSETOF(hcl_t,_or) }, { 2, { 'o','r' }, HCL_SYNCODE_OR, HCL_OFFSETOF(hcl_t,_or) },

View File

@ -1581,6 +1581,7 @@ struct hcl_t
hcl_oop_t _do; /* symbol */ hcl_oop_t _do; /* symbol */
hcl_oop_t _elif; /* symbol */ hcl_oop_t _elif; /* symbol */
hcl_oop_t _else; /* symbol */ hcl_oop_t _else; /* symbol */
hcl_oop_t _fun; /* symbol */
hcl_oop_t _if; /* symbol */ hcl_oop_t _if; /* symbol */
hcl_oop_t _lambda; /* symbol */ hcl_oop_t _lambda; /* symbol */
hcl_oop_t _or; /* symbol */ hcl_oop_t _or; /* symbol */

View File

@ -6,12 +6,18 @@ defun aaa(a b) {
set k (aaa 10 20); set k (aaa 10 20);
if (= k 30) { if (= k 30) { printf "OK\n"; }
printf "OK\n"; else { printf "ERROR\n"; };
}
else { ## --------------------------------------
printf "ERROR\n";
defun mkfun(t) {
return (fun(c) {
return (+ t c);
});
}; };
set f (mkfun 20);
set k (f 50);
if (= k 50) { printf "OK\n"; }
else { printf "ERROR\n"; };