rebcabin / masr

Meta ASR: replacement for aging ASDL
MIT License
4 stars 0 forks source link

`WhileLoop` doesn't conform to ASDL #33

Open rebcabin opened 1 year ago

rebcabin commented 1 year ago

Example from asr-expr1-dde511e.stdout has three parameters:

(WhileLoop
                                        () ;; one
                                        (NamedExpr
                                            (Var 2 a)
                                            (IntegerConstant 1 (Integer 4 []))
                                            (Integer 4 [])
                                        ) ;; two
                                        [(=
                                            (Var 2 y)
                                            (IntegerConstant 1 (Integer 4 []))
                                            ()
                                        )] ;; three
                                    )

but ASDL from ASDL_2023_APR_06_snapshot.asdl specifies only two:

    | WhileLoop(expr test, stmt* body)

The first argument in the Example is mysterious. I'll work around it for now.

certik commented 1 year ago

The current ASR definition is WhileLoop(identifier? name, expr test, stmt* body), the first argument is probably a "goto target" to jump to, this is needed if you have multiple nested loops and you are doing "break name" to a specific parent loop. There might be a better way to do it, but for now we use this mechanism. Python doesn't allow breaking to a parent loop, but Fortran does.

rebcabin commented 1 year ago

ok, that's neat! goto doesn't deserve its bad reputation!

Should the goto target perhaps be a symbol-ref? Or do we want a nice, refined type for goto-targets? or even labels, generically? What about computed gotos, where all the labels are numerical? perhaps the labels ought to be (s/or :numerical ::nat, :symbolic ::symbol-ref)?

On Thu, May 11, 2023 at 7:20 PM Ondřej Čertík @.***> wrote:

The current ASR definition is WhileLoop(identifier? name, expr test, stmt* body), the first argument is probably a "goto target" to jump to, this is needed if you have multiple nested loops and you are doing "break name" to a specific parent loop. There might be a better way to do it, but for now we use this mechanism. Python doesn't allow breaking to a parent loop, but Fortran does.

— Reply to this email directly, view it on GitHub https://github.com/rebcabin/masr/issues/33#issuecomment-1545011038, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABSRR3F2LKM3GTOUHXFWOTXFWM6NANCNFSM6AAAAAAX6ZGHEU . You are receiving this because you authored the thread.Message ID: @.***>

rebcabin commented 1 year ago

reopening as documentation reminder as requested by @certik