guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] tree-il->scheme improvements


From: Mark H Weaver
Subject: Re: [PATCH] tree-il->scheme improvements
Date: Sat, 03 Mar 2012 18:59:54 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux)

Hi Andy!

Andy Wingo <address@hidden> writes:

> On Fri 02 Mar 2012 00:40, Mark H Weaver <address@hidden> writes:
>
>>> Here's a significantly refactored version of my 'tree-il->scheme'
>>> improvements.
>
> All look great to me, please push.  Some time soon after you do it,
> would you mind also handling the merge to master?

Excellent!  I've pushed an improved version to stable-2.0, and will soon
merge to master as well.

We now have a psyntax-pp.scm with no gensym counters, which means that
in most cases, local changes to psyntax.scm should result in only local
changes to psyntax-pp.scm.

> WDYT about
>
>    (define* (do-decompile e env #:key (avoid-lambda? #t) ... 
>                           #:allow-other-keys)
>      ...)
>
>    (define (decompile-tree-il e env opts)
>      (apply do-decompile e env opts))
>
> instead of manually handling the keywords?

Good idea, I've done this.

>
>> +           (('if ('eqv? (? atom? v) ('quote a)) #t ('eqv? v ('quote b)))
>> +            `(memv ,v '(,a ,b)))
>
> This is not quite correct -- memv returns the rest of the list if it
> matches.

Oops, good catch!  I now perform this transformation only in test context.

>> +           (('let ((v e)) ('case v clauses ...))
>> +            (=> failure)
>
> I never knew this => failure feature of match :)

Yes, our documentation for (ice-9 match) is somewhat lacking.  It also
fails to mention that you can include the same pattern variable more
than once, in which case all occurrences must be equal?.

If anyone is looking for a project, it would be great to add more
details from <http://synthcode.com/scheme/chibi/lib/chibi/match.html>
into our manual.

>> +    ;; Repeatedly strip suffix of the form "-N", where N is a string
>> +    ;; that could be produced by number->string given a positive
>> +    ;; integer.  In other words, the first digit of N may not be 0.
>> +    (define compute-base-name
>> +      (let ((digits (string->char-set "0123456789")))
>> +        (define (base-name-string str)
>> +          (let* ((i (string-skip-right str digits)))
>> +            (if (and i (< (1+ i) (string-length str))
>> +                     (eq? #\- (string-ref str i))
>> +                     (not (eq? #\0 (string-ref str (1+ i)))))
>> +                (base-name-string (substring str 0 i))
>> +                str)))
>> +        (lambda (sym)
>> +          (string->symbol (base-name-string (symbol->string sym))))))
>
> Pretty nasty, but we should continue this conversation in the other
> thread.

What other thread?

> Maybe it would be made more clear by procedures like `gensym?' and
> `gensym-base' or something.  Dunno.

That's not quite right, because we need to do this for any identifier,
even if it wasn't created by 'gensym'.  Also, gensyms will not
necessarily continue to have the same suffix format as we use here in
'choose-output-names'.

    Thanks!
      Mark



reply via email to

[Prev in Thread] Current Thread [Next in Thread]