Masatake YAMATO | 1 Nov 09:58 2006

Re: Unified way to access the method name or generic inside from a method

> 3. Writing more tricky macros as part of a library
> 
> (After thinking what I want is not `retry-method'. What I think useful are
>  following special local variables:
> 
>       - `current-generic'
>       - `current-arguments'
> These are more generic.)
> 
> With `current-generic' and `current-arguments', people can implement more tricky macros
> in a LIBRARY. 

After re-thinking I found the way to provide `current-generic' and `current-arguments'
with a macro which expends `define-method'.

gosh> (define-method* foo (n m) (apply current-generic (cons 3 current-arguments)))
#<generic foo (5)>
gosh> (define-method* foo (n m x) (+ n m x))
#<generic foo (5)>
gosh> (foo 1 2)
6
gosh> 

(define-macro define-method* 
  (lambda (name specs . body)
    `(define-method ,name ,specs 
       (let ((current-generic ,(if (symbol? name) 
				   name
				   (car name)))
	     (current-arguments ,(let1 args (cond
(Continue reading)

Masatake YAMATO | 1 Nov 17:24 2006

overriding getter

Hi,

I got an error when running following code:

    (define-module a
      (export name-of <a>)
      (define-class <a> () ((name :init-value 'a :getter name-of))))
    (provide "a")
    (define-module b
      (export name-of <b>)
      (define-class <b> () ((name :init-value 'b :getter name-of))))
    (provide "b")

    (use a)
    (use b)
    (display (name-of (make <a>)))
    (display (name-of (make <b>)))

    $ gosh name-of-test.scm 
    *** ERROR: no applicable method for #<generic name-of (1)> with arguments (#<<a> 0x9be9660>)
    Stack Trace:
    _______________________________________
      0  (name-of (make <a>))
	    At line 12 of "./name-of-test.scm"

Is this expected behavior?
(I'd like to use name-of both <a> and <b>.)

Masatake YAMATO

(Continue reading)

Masatake YAMATO | 1 Nov 17:31 2006

Re: Unified way to access the method name or generic inside from a method

> (define-macro define-method* 
>   (lambda (name specs . body)
>     `(define-method ,name ,specs 
>        (let ((current-generic ,(if (symbol? name) 
> 				   name
> 				   (car name)))
> 	     (current-arguments ,(let1 args (cond
> 					     ((null? specs)
> 					      '())
> 					     ((pair? specs)
> 					      (let-values (((elt specs) (car+cdr specs)))
> 						(cons (if (symbol? elt)
> 							  elt
> 							  (car elt))
> 						      (specs->arguments specs))))
> 					     (else
> 					      specs))
> 				   (cond
> 				    ((list? args)
> 				     (cons 'list args))
> 				    ((pair? args)
> 				     ;;
> 				     `(append ,(cons 'list (drop-right args 0))
> 					      (list ,(take-right args 0))))
> 				    ;;
> 				    (else 
> 				     (specs->arguments specs))))))
> 	 
> 	 
> 	 , <at> body))))
(Continue reading)

Shiro Kawai | 1 Nov 20:48 2006
Picon

Re: overriding getter

It is a known issue.  Here's a page that discusses it (in Japanese):

http://practical-scheme.net/wiliki/wiliki.cgi?Gauche%3aGenericFunction%e3%81%a8Module

The fundamental cause is that CLOS-style generic-function
is not the way to overload a same method name between unrelated
classes (whereas in class-based OO you can casually use the
same method name between totally different classes).  That is,
since module a and b are unrelated, and class <a> and <b> are
also unrelated, the two generic functions 'name-of' *must* be
different entity albeit having the same name.

(In Common Lisp you cannot even import package a and b 
simultaneously unless you explicitly rename or shadow
either one of 'name-of'.)

You need to change the way of thinking from class-based or
message-based OO.  It's like this: Suppose you have a two headers
in C++, a.h which defines class FOO, and b.h which also
defines class FOO differently.  You cannot expect that
including both a.h and b.h magically merges two definitions
of FOO, right?  The similar thing is happening here on 
generic functions.

However, even knowing that I find this behavior is confusing.
Now I don't use getter/setter/accessor so much as before
because of this.  The main benefit of getter etc. is probably
a shorter code, but having 'ref' instead of 'slot-ref' I'm
not bothered much to write (ref obj 'name).   Slot access
in CLOS-style OOP is abstract enough so that you don't need
(Continue reading)

Raffael Cavallaro | 6 Nov 16:44 2006
Picon

Fast loading files?

Shiro and others who might be knowledgeable about this,

Since gauche actually compiles scheme files to an intermediate  
representation, doing macro expansion and compilation as separate  
phases before interpretation, would it be possible to write the  
resultant code vector to a file for faster loading, thus saving the  
time to compile and macroexpand the source the next time the file is  
loaded?

I've looked through the manual but I couldn't find anything that I  
could use for this purpose.

I ask because I am using c-wrapper to work with Apple's Cocoa  
framework and loading objc-wrapper, Foundation and Cocoa is taking  
about 15 seconds total on a 2 GHz intel imac. If I could shave some  
of this time off it would make for a quicker launching application.

Thanks in advance for any pointers or help,

warmest regards,

Ralph

Raffael Cavallaro, Ph.D.
raffaelcavallaro <at> mac.com

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
(Continue reading)

Shiro Kawai | 6 Nov 18:19 2006
Picon

Re: Fast loading files?

From: Raffael Cavallaro <raffaelcavallaro <at> mac.com>
Subject: [Gauche-devel] Fast loading files?
Date: Mon, 6 Nov 2006 10:44:16 -0500

> Since gauche actually compiles scheme files to an intermediate  
> representation, doing macro expansion and compilation as separate  
> phases before interpretation, would it be possible to write the  
> resultant code vector to a file for faster loading, thus saving the  
> time to compile and macroexpand the source the next time the file is  
> loaded?

Yes, indeed.  And actually the feature is already there in some
sense, although it isn't really a "fasl".

A part of Gauche is written by Gauche itself.  During build
process, Gauche compiles it to VM instruction sequence, and
write it out as static data in a C source file; then run C
compiler and link it in.

It's a kind of experiment stage.  Some popular modules, such as
srfi-1, are already 'pre-compiled', in order to make loading
faster.  It is not documented yet since I need to think more about
the compilation process, but I do plan to open the feature up
to users.

> I ask because I am using c-wrapper to work with Apple's Cocoa  
> framework and loading objc-wrapper, Foundation and Cocoa is taking  
> about 15 seconds total on a 2 GHz intel imac. If I could shave some  
> of this time off it would make for a quicker launching application.

(Continue reading)

Masatake YAMATO | 6 Nov 18:34 2006

Re: overriding getter

> It is a known issue.  Here's a page that discusses it (in Japanese):
> 
> http://practical-scheme.net/wiliki/wiliki.cgi?Gauche%3aGenericFunction%e3%81%a8Module
> 

Thank you. I should read these pages.

> The fundamental cause is that CLOS-style generic-function
> is not the way to overload a same method name between unrelated
> classes (whereas in class-based OO you can casually use the
> same method name between totally different classes).  That is,
> since module a and b are unrelated, and class <a> and <b> are
> also unrelated, the two generic functions 'name-of' *must* be
> different entity albeit having the same name.
> 
> (In Common Lisp you cannot even import package a and b 
> simultaneously unless you explicitly rename or shadow
> either one of 'name-of'.)
> 
> You need to change the way of thinking from class-based or
> message-based OO.  It's like this: Suppose you have a two headers
> in C++, a.h which defines class FOO, and b.h which also
> defines class FOO differently.  You cannot expect that
> including both a.h and b.h magically merges two definitions
> of FOO, right?  The similar thing is happening here on 
> generic functions.

I see...isn't is possible to add an option to gosh interpreter
which warns when <generic> is redefined? Is it bad idea?

(Continue reading)

Raffael Cavallaro | 6 Nov 20:11 2006
Picon

Re: Fast loading files?


On Nov 6, 2006, at 12:19 PM, Shiro Kawai wrote:

> I think c-wrapper is taking time since it parses header file at
> runtime.  IIRC, the author has mentioned a plan to have a feature
> to dump the parsed result, so it may be solved independently.

Do you mean the genwrapper facility? I've tested it and it does  
reduce the time taken from the 14-15  seconds I quoted in my first  
email to about 7.5 seconds. I was hoping to reduce this farther by  
"pre-compiling" the scheme files generated by genwrapper. Sounds like  
this is a feature that will probably make it into a future release.
Thanks for your help, and thanks for a really nice and very well  
documented scheme interpreter.

warmest regards,

Ralph

Raffael Cavallaro, Ph.D.
raffaelcavallaro <at> mac.com

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
Shiro Kawai | 12 Nov 12:11 2006
Picon

Gauche 0.8.8 & Gauche-gl 0.4.2

Release 0.8.8 is out.

http://practical-scheme.net/gauche/

This is, again, a major maintainance release.  Check out
the project webpage for the (long) list of changes.

--shiro

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
Thomas Hafner | 13 Nov 11:43 2006

binary for sparc64

Hello,

I cannot compile Gauche Scheme 0.8.8 for sparc64 due to lack of
ressources. Even the Sysadmin could not install the NetBSD 3.0 package
(v. 0.8.6), in addition it is marked as broken.

Maybe the machine hasn't just enough memory? In that case I could try
to get a binary that has been compiled by a better machine (i.e. one
having more memory). Has somebody successfully compiled for a target
like that? Shall I try to cross-compile?

Regards
  Thomas

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

Gmane