ver 0.10.0, about func's argument

19 views
Skip to first unread message

Minoru

unread,
Jun 24, 2026, 6:55:46 AM (6 days ago) Jun 24
to Extempore
Hi Ben,

Wah, ver 0.10.0 ! 
Thanks again !

I'm trying it now ..... and I found one thing again, compared with ver 0.8.9,  this s7 version has more strict evaluation method .... 

I will post it soon ....

Minoru

unread,
Jun 25, 2026, 12:16:39 AM (5 days ago) Jun 25
to Extempore
Hi Ben,

When I checked my tune's functions which worked in ver 0.8.9, then one func stopped because error.
What happend this time ???

messages are ........
;(lambda () (random '(1/2 1/2 1/2 1 2))): too many arguments: ((lambda () ...) 0)
;    (lambda () (random '(1/2 1/2 1/2 1 2)))
;    *stdout*, line 11, position: 556
pia1: (lambda () (random '(1/2 1/2 1/2 1 ...
make-list-with-proc: (cons (func i) lst)     ; i: 0, lst: ()
........... and so on ....


What does "too many arguments: ((lambda () ...) 0)" mean ??

Of course, after thinking about it, this lambda expression has no argument but this func was passed one argument 0, so system said too many arguments, maybe ...

A real code in my func is below, though some parts of this code are deleted to simplify original one for this posting.

(make-list-with-proc n (lambda ()(random '(1/2 1/2 1/2 1 2))))

So I checked make-list-with-proc, in ver 0.7 and ver 0.10.0, no difference, ver 0.10.0 has broken indentaition though.

files : .../extempore-n.n./runtime/scheme.xtm

(define (make-list-with-proc lth func)
  (if (< lth 1)
      '()
      (let loop ((i 0)
                 (lst '()))
        (if (>= i lth)
            (reverse lst)
            (loop (+ i 1) (cons (func i) lst))))))  ; <-------

Oh yes, at last line, func is passed i, so func should have at least one argument !
So I fixed like this ...

(make-list-with-proc n (lambda (_)(random '(1/2 1/2 1/2 1 2))))

Ok, it works well again without error.!

Then I tested like below ......

;; ver 0.8.9 !
;; Oh! these have no error !
(define t10 (lambda () (random '(1 2 3)))) ; t10 has no argument
(t10) ; ok, this is no problem
(t10 5) ;OK  wah  (of course, error in s7)
(t10 5 10) ;OK  waoh !!! (of course, error in s7)

It seems like that the function which has no argement is passed one or more arguments witout any error in tinyscheme !!


;; s7
(make-list-with-proc 4 (lambda (_)(random '(1 2 1/2 3)))) ; ok

(define t1 (lambda () (random '(1 2 3))))
(t1)
(make-list-with-proc 3 t1) ;error, because t1 doesn't have argument

(define t2 (lambda (_) (random '(1 2 3))))
(t2 100);ok

;; ok, because t2 has one argument, not used though
(make-list-with-proc 3 t2)

;; ok, just same as above, just a anonymous function
(make-list-with-proc 3 (lambda (_) (random '(1 2 3))))

(make-list-with-proc 3 random) ;ok bacause random has variadic arguments
(make-list-with-proc 3 print) ;ok because print has variadic argument

s7 seems to evaluate the S-expression more strictly, according to the function definition.

2026年6月24日水曜日 19:55:46 UTC+9 Minoru:

Ben Swift

unread,
Jun 25, 2026, 7:24:30 PM (4 days ago) Jun 25
to extemp...@googlegroups.com
Hi Minoru,

Your diagnosis is right, this is s7 being stricter than the old TinyScheme. TinyScheme silently ignored extra arguments, so a zero-argument (lambda () ...) worked even though make-list-with-proc calls it with the index. s7 follows R7RS and enforces argument counts, so it now (correctly) errors. Your fix is the right one:

(make-list-with-proc n (lambda (_) (random '(1/2 1/2 1/2 1 2))))

The _ just names the unused index argument. Use that pattern anywhere you pass a procedure to make-list-with-proc.

Good catch on the broken indentation in scheme.xtm, too --- that came from an old whitespace cleanup, not from your code. I've just reindented the whole source tree consistently, so it'll look right in the next version.

Cheers,
Ben
>--
>You received this message because you are subscribed to the Google Groups "Extempore" group.
>To unsubscribe from this group and stop receiving emails from it, send an email to extemporelan...@googlegroups.com.
>To view this discussion visit https://groups.google.com/d/msgid/extemporelang/4951b689-0ec2-41aa-8d56-f22cd5eb911dn%40googlegroups.com.


--

Cheers,
Ben

Minoru

unread,
Jun 27, 2026, 1:06:50 AM (3 days ago) Jun 27
to Extempore
Hi Ben,

I always appreciate your support.


Reply all
Reply to author
Forward
0 new messages