This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

SRFI 26: Macros for partial parameterisation


I've just been playing around with Sebastian Egner's SRFI 26, "Notation
for Specializing Parameters without Currying" ( http://srfi.schemers.org/srfi-26/ ). 
It provides macros that construct new functions from old by fixing some of
the parameters. Nothing that can't be done with lambda, of course, but
much more concise.

Examples:
  (cut cons 1 <>) = (lambda (x) (cons 1 x)) 
    Fixes the first parameter to cons.

  (cut cons <> 1) = (lambda (x) (cons x 1))
    Fixes the second parameter.

In general, cut takes the name of the function followed by a sequence of
values and "slot markers" indicated by the <> symbol. Parameter positions
marked by <> are left open, while the others are filled in by the values:
  #|kawa:5|# ( (cut list 1 <> 2 <> 3) 'a 'b)
  (1 a 2 b 3)

If anyone is collecting SRFIs for distribution with Kawa, you may like to
know that the library loaded and ran the author's test cases without any
modification, and also seems to work when compiled; I don't see anything
in the code that I wouldn't expect Kawa to handle.

Jocelyn Paine
http://www.ifs.org.uk/~popx/
+44 (0)7768 534 091 




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]