Python on guile

2020-03-22 Thread Stefan Israelsson Tampe
Hi all,

Now in corona times I'm working quite a lot with python-on-guile fixing
bugs in the parser and compiler. Trying to add and test more python
modules. My test case is to get IPython running on python on guile. Some of
the python library code is very advanced python so getting it working is a
great test case. My latest addition is to generate AST from python code. I
have an AST of my own but the translation is quite transparent. I also
managed to get the python typing.py module compiling and running. That was
quite a challenge as it is quite a lot af meta programming that was hard to
get working. I also have been working hard to get autocompilation of python
code working for guile 3.0.0 and are quite happy now with it. I also
sielenced a lot of variable warnings that was wrong. So no usually those
warnings are spot on and very helpful. I will continue to work on getting
better feedback in the compiler to detect errors. I also want to see if I
can do anything with the ctypes package as well. I think the gule ffi is
comparable to ctypes. Else I will continue to see what I can do with the
ipython package.

Happy Hacking


Re: definitions in macros?

2020-03-22 Thread David Kastrup
Han-Wen Nienhuys  writes:

> Hi there,
>
> in my quest to get lilypond working with GUILE 2+, I've hit another
> stumbling block.
>
> In order to make compilation with GUILE 2+ working, we have to move
> away from runtime symbol definition (ie. module-define! calls).
>
> In the code below, it looks like only one of the two definitions in
> the body of my-macro-new takes effect. Is this expected, and if so,
> why?
>
> (defmacro-public my-macro-old (command-and-args . definition)
>   (module-define! (current-module) 'x1 "I am X1\n")
>   (module-define! (current-module) 'x2 "I am X2\n"))
>
> (defmacro-public my-macro-new (command-and-args . definition)
> `(define p "i am P\n")
> `(define q "i am Q\n"))

This is very much expected.  The macro body contains two side-effect
free expressions (namely quoted lists) and returns the last one which is

(define q "i am Q\n")

This then gets evaluated at run time, defining q .

You probably wanted something like
  `(begin (define p ...) (define q ...))

as your body (and return expression) instead.

> (my-macro-old 1 2)
> (my-macro-new 1 2)
> (display x1)
> (display x2)
> (display q)
> (display p)
>
>
> thanks,

-- 
David Kastrup



Re: definitions in macros?

2020-03-22 Thread Matt Wette

On 3/22/20 12:07 PM, Han-Wen Nienhuys wrote:

Hi there,

in my quest to get lilypond working with GUILE 2+, I've hit another
stumbling block.

In order to make compilation with GUILE 2+ working, we have to move
away from runtime symbol definition (ie. module-define! calls).

In the code below, it looks like only one of the two definitions in
the body of my-macro-new takes effect. Is this expected, and if so,
why?

(defmacro-public my-macro-old (command-and-args . definition)
   (module-define! (current-module) 'x1 "I am X1\n")
   (module-define! (current-module) 'x2 "I am X2\n"))

(defmacro-public my-macro-new (command-and-args . definition)
 `(define p "i am P\n")
 `(define q "i am Q\n"))


(my-macro-old 1 2)
(my-macro-new 1 2)
(display x1)
(display x2)
(display q)
(display p)


thanks,



Try the following.  Not sure about defmacro but define-syntax must 
return a single form.


(defmacro-public my-macro-new (command-and-args . definition)
`(begin
  (define p "i am P\n")
  (define q "i am Q\n")))

 







definitions in macros?

2020-03-22 Thread Han-Wen Nienhuys
Hi there,

in my quest to get lilypond working with GUILE 2+, I've hit another
stumbling block.

In order to make compilation with GUILE 2+ working, we have to move
away from runtime symbol definition (ie. module-define! calls).

In the code below, it looks like only one of the two definitions in
the body of my-macro-new takes effect. Is this expected, and if so,
why?

(defmacro-public my-macro-old (command-and-args . definition)
  (module-define! (current-module) 'x1 "I am X1\n")
  (module-define! (current-module) 'x2 "I am X2\n"))

(defmacro-public my-macro-new (command-and-args . definition)
`(define p "i am P\n")
`(define q "i am Q\n"))


(my-macro-old 1 2)
(my-macro-new 1 2)
(display x1)
(display x2)
(display q)
(display p)


thanks,

-- 
Han-Wen Nienhuys - hanw...@gmail.com - http://www.xs4all.nl/~hanwen