public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
From: Damien Mattei <damien.mattei@gmail.com>
To: kawa mailing list <kawa@sourceware.org>
Subject: Re: n arity with method
Date: Sun, 19 Nov 2023 08:23:34 +0100	[thread overview]
Message-ID: <CADEOadcHg_ZSe+szAn401-Aim1Q_g39+7pQ4HxcY-KNkAM6X9w@mail.gmail.com> (raw)
In-Reply-To: <CADEOadctHh3aSpVX2FwREfcSK4vnrqGYE4=E9y4b4ouDdsg3CA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3136 bytes --]

when comparing speed on the first part of my program written in Scheme+ it
run in 15" with Kawa and 7" in Racket.
the speed is the same in all kawa version.
the REPL version is:
https://github.com/damien-mattei/AI_Deep_Learning/blob/main/exo_retropropagationNhidden_layers_matrix_v2_by_vectors4kawa%2B.scm
the compiled classes version is:
https://github.com/damien-mattei/AI_Deep_Learning/blob/main/exo_retropropagationNhidden_layers_matrix_v2_by_vectors4kawa_classes%2B.scm
the new and latest version of Scheme+ for Kawa is now tested and available
here:

https://github.com/damien-mattei/Scheme-PLUS-for-Kawa

docs are  here:
https://damien-mattei.github.io/Scheme-PLUS-for-Racket/Scheme+io.html


On Sat, Nov 18, 2023 at 12:14 PM Damien Mattei <damien.mattei@gmail.com>
wrote:

> seems there is some difference in 'load' and 'import' ,the same program
> can run with 'load' and not with 'import'
> about the overloading of n-arity operators i find a solution in
> 'define-method' :
>
> (define ⋅ (make-procedure method: (lambda (x ::number y ::number) (* x y))
>  method: (lambda (x ::matrix y ::matrix) (multiply-matrix-matrix  x y))
>  method: (lambda (x ::matrix y ::vector) (multiply-matrix-vector  x y))
>  method: (lambda lyst (apply * lyst))))
>
>
> (insert-operator! * ⋅)
>
> kawa -d classes
> -Dkawa.import.path=".:/Users/mattei/Scheme-PLUS-for-Kawa:./kawa" -C
> exo_retropropagationNhidden_layers_matrix_v2_by_vectors4kawa_classes.scm
>
> i hoped to have a speed up by compiling the kawa code in .class files but
> it is the same , i suppose that 'load' compile the code , ad he does it
> with more easyness than 'require' , with 'load' the overloading features of
> Scheme+ worked fine , not with 'require'
>
>
>
> On Thu, Nov 16, 2023 at 11:53 PM Damien Mattei <damien.mattei@gmail.com>
> wrote:
>
>> (import (rename (scheme base) (* orig*)))
>>
>> (define * (make-procedure method: (lambda (x ::number y ::number) (orig*
>> x y))
>>  method: (lambda (x ::matrix y ::matrix) (multiply-matrix-matrix  x y))
>>  method: (lambda (x ::matrix y ::vector) (multiply-matrix-vector  x y))))
>>
>> is there a way to still have * a n-arity operator with typed methods ?
>> because now i have this error:
>> (* 2 3 4)
>> Argument  (null) has wrong type
>> at gnu.mapping.CallContext.matchError(CallContext.java:185)
>> at gnu.expr.GenericProc.applyToConsumerGP(GenericProc.java:132)
>> at gnu.kawa.functions.ApplyToArgs.applyToConsumerA2A(ApplyToArgs.java:132)
>> at gnu.mapping.CallContext.runUntilDone(CallContext.java:586)
>> at gnu.expr.ModuleExp.evalModule2(ModuleExp.java:343)
>> at gnu.expr.ModuleExp.evalModule(ModuleExp.java:211)
>> at kawa.Shell.run(Shell.java:289)
>> at kawa.Shell.run(Shell.java:196)
>> at kawa.Shell.run(Shell.java:183)
>> at kawa.repl.processArgs(repl.java:724)
>> at kawa.repl.main(repl.java:830)
>> the problem is that * is no more n-arity operator now
>>
>> Damien
>>
>> anyway there is perheaps a possibility of using a variable number of args
>> but i did not think it this evening.... perheaps tomorrow...
>>
>

  reply	other threads:[~2023-11-19  7:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-16 22:53 Damien Mattei
2023-11-18 11:14 ` Damien Mattei
2023-11-19  7:23   ` Damien Mattei [this message]
2023-11-19 17:50     ` Per Bothner
2023-11-20 13:51       ` Damien Mattei
2023-11-21  8:48         ` Damien Mattei
2023-11-22 10:03           ` Damien Mattei

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CADEOadcHg_ZSe+szAn401-Aim1Q_g39+7pQ4HxcY-KNkAM6X9w@mail.gmail.com \
    --to=damien.mattei@gmail.com \
    --cc=kawa@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).