Changeset 39485 in project


Ignore:
Timestamp:
01/06/21 17:34:36 (11 days ago)
Author:
juergen
Message:

dotted-lambdas 1.1

Location:
release/5/dotted-lambdas
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • release/5/dotted-lambdas/tags/1.1/dotted-lambdas.egg

    r38999 r39485  
    33((synopsis "lambda equivalents with dots as trailing symbols")
    44 (category lang-exts)
    5  (version "1.0")
     5 (version "1.1")
    66 (license "BSD")
    77 (test-dependencies simple-tests)
  • release/5/dotted-lambdas/tags/1.1/dotted-lambdas.scm

    r38999 r39485  
    1 ; Copyright (c) 2020 , Juergen Lorenz, ju (at) jugilo (dot) de
     1; Copyright (c) 2021 , Juergen Lorenz, ju (at) jugilo (dot) de
    22; All rights reserved.
    33;
     
    3636last item is one of the symbols .., ... or ....
    3737
    38 The meaning of theses symbols, which are ledal identifiers, is
     38The meaning of theses symbols, which are legal identifiers, is
    3939
    4040* two dots:   the argument to the left references a callable list
     
    6464  callable
    6565  lambda*
     66  define*
    6667  dotted-lambdas
    6768  )
     
    9798The last one evaluates to ordinary (lambda (x ...) xpr . xprs)
    9899]|#
    99 
    100100(define-syntax lambda*
    101101  (syntax-rules !!! (.. ... ....)
     
    113113       (if (null? xs)
    114114         (error 'lambda* "not enough arguments for ...." xs)
    115          (let ((xs (make-callable xs))) xpr . xprs))))
     115         (let ((xs (callable xs))) xpr . xprs))))
    116116    ((_ (x !!!) xpr . xprs) ; without dots: normal lambda
    117117     (lambda (x !!!) xpr . xprs))
     
    119119
    120120; Note, that ... as well as .. and .... are legal Scheme identifiers
     121
     122#|[
     123(define* (name x ... xs ..) xpr . xprs)
     124(define* (name x ... xs ...) xpr . xprs)
     125(define* (name x ... xs ....) xpr . xprs)
     126(define* (name x ...) xpr . xprs)
     127--- macro ---
     128syntactic sugar for, e.g.
     129(define name (lambda* (x ... xs ..) xpr . xprs))
     130]|#
     131(define-syntax define*
     132  (syntax-rules !!! (.. ... ....)
     133    ((_ (name x !!! xs ..) xpr . xprs)
     134     (define name (lambda* (x !!! xs ..) xpr . xprs)))
     135    ((_ (name x !!! xs ...) xpr . xprs)
     136     (define name (lambda* (x !!! xs ...) xpr . xprs)))
     137    ((_ (name x !!! xs ....) xpr . xprs)
     138     (define name (lambda* (x !!! xs ....) xpr . xprs)))
     139    ((_ (name x !!!) xpr . xprs)
     140     (define name (lambda* (x !!!) xpr . xprs)))
     141    ))
    121142
    122143#|[
     
    148169        "The last one evaluates to ordinary (lambda (x ...) xpr . xprs)"
    149170        )
     171      (define
     172        macro:
     173        (define* (name x ... xs ..) xpr . xprs)
     174        (define* (name x ... xs ...) xpr . xprs)
     175        (define* (name x ... xs ....) xpr . xprs)
     176        (define* (name x ...) xpr . xprs)
     177        (define name (lambda* (x ... xs ..) xpr . xprs))
     178        "syntactic sugar for, e.g."
     179        )
    150180      (dotted-lambdas
    151181        procedure:
  • release/5/dotted-lambdas/tags/1.1/tests/run.scm

    r38999 r39485  
     1(import dotted-lambdas)
    12
    2 (import dotted-lambdas simple-tests (chicken condition))
     3(import simple-tests (chicken base) (chicken condition))
    34
    45(define-checks
     
    4041  '())
    4142
     43(define* (inc x i ..) (+ x (optional (i) 1)))
     44
     45(define* (foo x y zs ...) (list x y (zs)))
     46
     47(define* (bar x ys ....) (list x (ys)))
     48
     49(define* (baz xs ..) (list (xs)))
     50
     51(define-checks
     52  (defines verbose?)
     53  (inc 5)
     54  6
     55  (inc 5 3)
     56  8
     57  (foo 1 2 3 4)
     58  '(1 2 (3 4))
     59  (foo 1 2)
     60  '(1 2 ())
     61  (bar 1 2 3 4)
     62  '(1 (2 3 4))
     63  (condition-case (bar 1) ((exn) #f))
     64  #f
     65  (baz 1)
     66  '((1))
     67  (condition-case (baz 1 2) ((exn) #f))
     68  #f)
     69
    4270(check-all DOTTED-LAMBDAS
    4371  (calls)
    4472  (lambdas)
     73  (defines)
    4574  )
  • release/5/dotted-lambdas/trunk/dotted-lambdas.egg

    r38999 r39485  
    33((synopsis "lambda equivalents with dots as trailing symbols")
    44 (category lang-exts)
    5  (version "1.0")
     5 (version "1.1")
    66 (license "BSD")
    77 (test-dependencies simple-tests)
  • release/5/dotted-lambdas/trunk/dotted-lambdas.scm

    r38999 r39485  
    1 ; Copyright (c) 2020 , Juergen Lorenz, ju (at) jugilo (dot) de
     1; Copyright (c) 2021 , Juergen Lorenz, ju (at) jugilo (dot) de
    22; All rights reserved.
    33;
     
    3636last item is one of the symbols .., ... or ....
    3737
    38 The meaning of theses symbols, which are ledal identifiers, is
     38The meaning of theses symbols, which are legal identifiers, is
    3939
    4040* two dots:   the argument to the left references a callable list
     
    6464  callable
    6565  lambda*
     66  define*
    6667  dotted-lambdas
    6768  )
     
    9798The last one evaluates to ordinary (lambda (x ...) xpr . xprs)
    9899]|#
    99 
    100100(define-syntax lambda*
    101101  (syntax-rules !!! (.. ... ....)
     
    113113       (if (null? xs)
    114114         (error 'lambda* "not enough arguments for ...." xs)
    115          (let ((xs (make-callable xs))) xpr . xprs))))
     115         (let ((xs (callable xs))) xpr . xprs))))
    116116    ((_ (x !!!) xpr . xprs) ; without dots: normal lambda
    117117     (lambda (x !!!) xpr . xprs))
     
    119119
    120120; Note, that ... as well as .. and .... are legal Scheme identifiers
     121
     122#|[
     123(define* (name x ... xs ..) xpr . xprs)
     124(define* (name x ... xs ...) xpr . xprs)
     125(define* (name x ... xs ....) xpr . xprs)
     126(define* (name x ...) xpr . xprs)
     127--- macro ---
     128syntactic sugar for, e.g.
     129(define name (lambda* (x ... xs ..) xpr . xprs))
     130]|#
     131(define-syntax define*
     132  (syntax-rules !!! (.. ... ....)
     133    ((_ (name x !!! xs ..) xpr . xprs)
     134     (define name (lambda* (x !!! xs ..) xpr . xprs)))
     135    ((_ (name x !!! xs ...) xpr . xprs)
     136     (define name (lambda* (x !!! xs ...) xpr . xprs)))
     137    ((_ (name x !!! xs ....) xpr . xprs)
     138     (define name (lambda* (x !!! xs ....) xpr . xprs)))
     139    ((_ (name x !!!) xpr . xprs)
     140     (define name (lambda* (x !!!) xpr . xprs)))
     141    ))
    121142
    122143#|[
     
    148169        "The last one evaluates to ordinary (lambda (x ...) xpr . xprs)"
    149170        )
     171      (define
     172        macro:
     173        (define* (name x ... xs ..) xpr . xprs)
     174        (define* (name x ... xs ...) xpr . xprs)
     175        (define* (name x ... xs ....) xpr . xprs)
     176        (define* (name x ...) xpr . xprs)
     177        (define name (lambda* (x ... xs ..) xpr . xprs))
     178        "syntactic sugar for, e.g."
     179        )
    150180      (dotted-lambdas
    151181        procedure:
  • release/5/dotted-lambdas/trunk/tests/run.scm

    r38999 r39485  
     1(import dotted-lambdas)
    12
    2 (import dotted-lambdas simple-tests (chicken condition))
     3(import simple-tests (chicken base) (chicken condition))
    34
    45(define-checks
     
    4041  '())
    4142
     43(define* (inc x i ..) (+ x (optional (i) 1)))
     44
     45(define* (foo x y zs ...) (list x y (zs)))
     46
     47(define* (bar x ys ....) (list x (ys)))
     48
     49(define* (baz xs ..) (list (xs)))
     50
     51(define-checks
     52  (defines verbose?)
     53  (inc 5)
     54  6
     55  (inc 5 3)
     56  8
     57  (foo 1 2 3 4)
     58  '(1 2 (3 4))
     59  (foo 1 2)
     60  '(1 2 ())
     61  (bar 1 2 3 4)
     62  '(1 (2 3 4))
     63  (condition-case (bar 1) ((exn) #f))
     64  #f
     65  (baz 1)
     66  '((1))
     67  (condition-case (baz 1 2) ((exn) #f))
     68  #f)
     69
    4270(check-all DOTTED-LAMBDAS
    4371  (calls)
    4472  (lambdas)
     73  (defines)
    4574  )
Note: See TracChangeset for help on using the changeset viewer.