For Programmers: Free Programming Magazines  


Home > Archive > Scheme > June 2007 > Re: Silly question - Why doesn't a non-procedure expr evaluate to itself in a procedu









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Silly question - Why doesn't a non-procedure expr evaluate to itself in a procedu
Shiro Kawai

2007-06-15, 7:13 pm

Gauche has similar mechanism. An application (x y ...) is handled by
a
generic function call (object-apply x y ...); by specializing object-
apply,
you can define your own semantics.

(define-method object-apply ((x <number> ))
x)

(define-method object-apply ((x <number> ) (y <number> ))
(* x y)) ;; for fun

Then:

gosh> (123)
123
gosh> (123 456)
56088

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com