[honu] use a function keyword to define procedures and make lambdas
This commit is contained in:
parent
1b6cf730c3
commit
54449d824c
|
@ -46,7 +46,13 @@
|
|||
(define-honu-syntax honu-function
|
||||
(lambda (code context)
|
||||
(syntax-parse code #:literal-sets (cruft)
|
||||
[(_ (#%parens arg:identifier ...)
|
||||
[(_ name:identifier (#%parens (~seq arg:identifier (~optional honu-comma)) ...)
|
||||
(#%braces code ...) . rest)
|
||||
(values
|
||||
#'(%racket (define (name arg ...) (parse-body code ...)))
|
||||
#'rest
|
||||
#f)]
|
||||
[(_ (#%parens (~seq arg:identifier (~optional honu-comma)) ...)
|
||||
(#%braces code ...)
|
||||
. rest)
|
||||
(values
|
||||
|
|
|
@ -371,6 +371,7 @@
|
|||
(when (not (stx-null? unparsed))
|
||||
(raise-syntax-error 'parse "found unparsed input" unparsed))
|
||||
(values (parse-all #'(more ...)) #'rest)]
|
||||
#;
|
||||
[(left:no-left function:honu-function . rest)
|
||||
(values #'function.result #'rest)]
|
||||
[else (syntax-parse #'head
|
||||
|
|
|
@ -80,10 +80,10 @@
|
|||
(test
|
||||
"function call"
|
||||
@input{
|
||||
foo(x){
|
||||
function foo(x){
|
||||
x * 2
|
||||
}
|
||||
foo(5);
|
||||
foo(5)
|
||||
}
|
||||
|
||||
@output{10
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#lang honu
|
||||
|
||||
|
||||
foo(){
|
||||
1 + 2
|
||||
function foo(x){
|
||||
1 + x * 2
|
||||
}
|
||||
|
||||
foo(5)
|
||||
|
|
|
@ -19,18 +19,18 @@ class Xml(data){
|
|||
getData(){ data }
|
||||
}
|
||||
|
||||
read_xml(){
|
||||
function read_xml(){
|
||||
xml_permissive_xexprs(true)
|
||||
xml_xml_to_xexpr(xml_document_element(xml_read_xml()))
|
||||
}
|
||||
|
||||
loadXml(file){
|
||||
function loadXml(file){
|
||||
withInputFromFile(file){
|
||||
new Xml(read_xml())
|
||||
}
|
||||
}
|
||||
|
||||
starts_with(start, what){
|
||||
function starts_with(start, what){
|
||||
substring(what, 0, string_length(start)) string_equal start
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user