Re: #:printer filed in language specification.

2021-09-20 Thread Zelphir Kaltstahl
Hi Maxim!

Thank you for your reply!

I do not know how to create such a vtable, what it means to have a vtalbe which
is `` or how to set it for a struct, but I should have
a look at the manual and see, what comes up when searching for vtable.

Regards,
Zelphir

On 9/19/21 2:24 PM, Maxime Devos wrote:
> Zelphir Kaltstahl schreef op zo 19-09-2021 om 12:11 [+]:
>> Hi Maxim!
>>
>> Do you know of any simple example anywhere for applicable structs? I might 
>> have
>> another use for them.
> From NEWS in the Guile source code:
>
>   ** Applicable struct support
>
>   One may now make structs from Scheme that may be applied as procedures.
>   To do so, make a struct whose vtable is `'.
>   That struct will be the vtable of your applicable structs; instances of
>   that new struct are assumed to have the procedure in their first slot.
>   `' is like Common Lisp's
>   `funcallable-standard-class'. Likewise there is
>   `', which looks for the setter in
>   the second slot. This needs to be better documented.
>
> For a not-very-simple example, see modules/oop/gooops.scm in Guile's source 
> code.
> I don't know any simple examples.
>
> Greetings,
> Maxime.

-- 
repositories: https://notabug.org/ZelphirKaltstahl




Re: macro syntax-error works in prefix but not curly-infix

2021-09-20 Thread Damien Mattei
hello Zelphir,

i understood my error, all was ok is just that  it convert this way:
'{x <+ 2 3}
($nfx$ x <+ 2 3)

in general the prefix notation of  {1 <+ 2 3 4 ...} is not (<+ 1 2 3 4 ...)
because (<+ 1 2 3 4 ...) in infix is {1 <+ 2 <+ 3 <+ 4 <+ ...}

it a stupid error of mine

i will drop the error case in macro and let Scheme deal with the error
itself ,he do it fine...
we message like that:

Syntax error:
unknown location: source expression failed to match any pattern in form <+

i find the error because thinking to ellipsis make me thiink to multiple
expressions in my <+ operator,anyway you help me, thank you

<+ is just in this case a define:

scheme@(guile-user)> {x <+ 7}
scheme@(guile-user)> x
7
he must be an unary operator , it does not allow multiple arity, but that
could be an idea like in C or as far as i remember one can writ x=y=7,
anyway in scheme it would be harder because SRFI 105 does not deal with
precedence... well i will do that in the future  and such writing as x=y=7
is not often used
thank you


damien


On Sun, Sep 19, 2021 at 2:34 PM Zelphir Kaltstahl <
zelphirkaltst...@posteo.de> wrote:

> Hi Damien!
>
> I think there might be too few expressions matched in the first case: (_
> var expr). Wouldn't it have to be:
>
> 
> (_ var expr1 expr2)
> ;; or
> (_ var exprs ...)
> 
>
> for
>
> 
> (<+ var expr1 expr2)
> 
>
> to work, simply because of the number of expressions there?
>
> But then you might need to use ellipsis in the resulting syntax somewhere,
> otherwise you get:
>
> 
> syntax: missing ellipsis in form (syntax (define var expr))
> 
>
> I don't know where that would go, but I also do not understand yet the
> goal. I think it is best to always describe, what you want to achieve, when
> you write a macro.
>
> Regards,
> Zelphir
> On 9/4/21 4:41 PM, Damien Mattei wrote:
>
> hi,
>
> i have this macro:
>
> (define-syntax <+
>   (syntax-rules ()
> ((_ var expr) (define var expr))
> ((_ err ...) (syntax-error "Bad <- form")) ;; does not work in infix !
> ))
>
> why my syntax-error pattern never reach in infix:
>
> scheme@(guile-user)> {x <+ 7 8}
> While compiling expression:
> Syntax error:
> unknown file:3:3: source expression failed to match any pattern in form <+
>
> but ok in prefix:
>
> scheme@(guile-user)> (<+ x 9 10)
> While compiling expression:
> Syntax error:
> unknown location: <+: Bad <- form in form (<+ x 9 10)
>
> why?
> Regards,
> Damien
>
> --
> repositories: https://notabug.org/ZelphirKaltstahl
>
>


Re: [Utkarsh Singh] Undefined simultaneous definitions

2021-09-20 Thread Utkarsh Singh
On 2021-09-20, 14:07 +0200, Stefan Israelsson Tampe  
wrote:

Note: Now I am using Guile straight out of main branch.

> I tested your code on my machine, it works! What version of guile are you
> using?

Again I think there is a confusion.  The program I have written compiles
correctly BUT the output of the program in not desirable.  Here is a
test:

1. Load "ambeval.scm"
2. Type (driver-loop) into your REPL session.
3. Copy and Paste following snippet:

   (define (findout32 x)
(letrec ((even?
  (lambda (n)
(if (= n 0)
#t
(odd? (- n 1)
 (odd?
  (lambda (n)
(if (= n 0)
#f
(even? (- n 1))
  (cond
   ((even? x) 20)
   ((odd? x) 30)
   (else 40

4. Type (findout32 10)

Output/Error:

;;; Starting a new problem ERROR: In procedure scm-error:
Unassigned variable -- LOOKUP-VARIABLE-VALUE odd?

Expected Output:

20

All the best,
Utkarsh Singh

-- 
Utkarsh Singh
https://utkarshsingh.xyz/