[cl-unification-devel] Re: [CL-UNIFICATION] MATCH, MATCHING macro's bug?

Marco Antoniotti marcoxa at cs.nyu.edu
Wed Apr 18 09:08:48 UTC 2007


Hi Masayuki,

thanks.  Yep.  You are right.

Please stand by for a few days before these changes make it in the  
codebase.

Cheers

Marco




On Apr 18, 2007, at 12:35 AM, Masayuki Onjo wrote:

> Hi, Marco
>
>> it looks like the patch is good.
>>
>> Let me do a few tests and I will check it in.
>
> Thanks!
>
> I'm enjoying UNIFICATION power. The pattern matching is fun. :-)
> There are some more bugs in CONTROL-FLOW macros.
>
> CL-USER> (macroexpand-1 '(unify:match-case (x) (0 1) (1 2) (2 3)
> (otherwise -1)))
> (LET ((#:OBJECT-VAR-3066 X))
>  (HANDLER-CASE (CL.EXT.DACF.UNIFICATION:MATCH (0 #:OBJECT-VAR-3066) 1)
>                (CL.EXT.DACF.UNIFICATION::UNIFICATION-FAILURE NIL
>                 (HANDLER-CASE
>                  (CL.EXT.DACF.UNIFICATION:MATCH (1 #:OBJECT- 
> VAR-3066) 2)
>                  (CL.EXT.DACF.UNIFICATION::UNIFICATION-FAILURE NIL
>                   (HANDLER-CASE
>                    (CL.EXT.DACF.UNIFICATION:MATCH (2 #:OBJECT- 
> VAR-3066) 3)
>                    (CL.EXT.DACF.UNIFICATION::UNIFICATION-FAILURE NIL
>                     (OTHERWISE -1))))))))
>
> I think (OTHERWISE -1) must be (PROGN -1) and
>
> CL-USER> (macroexpand-1 '(unify:matching () ((0 x) 1) ((1 y) 2)  
> (otherwise -1)))
> (BLOCK CL.EXT.DACF.UNIFICATION:MATCHING
>  (COND
>   ((SETF #:UNIFICATION-ENV-3070
>            (IGNORE-ERRORS
>             (CL.EXT.DACF.UNIFICATION:UNIFY '0 X
>
> (CL.EXT.DACF.UNIFICATION:MAKE-EMPTY-ENVIRONMENT))))
>    (LET* ()
>      1))
>   ((SETF #:UNIFICATION-ENV-3071
>            (IGNORE-ERRORS
>             (CL.EXT.DACF.UNIFICATION:UNIFY '1 Y
>
> (CL.EXT.DACF.UNIFICATION:MAKE-EMPTY-ENVIRONMENT))))
>    (LET* ()
>      2))
>   (NIL
>    (ERROR 'CL.EXT.DACF.UNIFICATION::UNIFICATION-NON- 
> EXHAUSTIVE :FORMAT-CONTROL
>           "Non exhaustive matching."))
>   (OTHERWISE -1)))
>
> (OTHERWISE -1) should be (T -1), too. I made following patch.
>
> Index: match-block.lisp
> ===================================================================
> RCS file: /project/cl-unification/cvsroot/cl-unification/match- 
> block.lisp,v
> retrieving revision 1.6
> diff -r1.6 match-block.lisp
> 13c13
> <                            (substitution (make-empty-environment))
> ---
>>                            (substitution '(make-empty-environment))
> 63c63
> <                           (default-substitution (make-empty- 
> environment)))
> ---
>>                           (default-substitution '(make-empty- 
>> environment)))
> 139c139
> <              ,@(when default-clause (list default-clause)))))
> ---
>>              ,@(when default-clause (list `(T ,(cdr default- 
>> clause)))))))
> 191c191
> <                  otherwise-clause
> ---
>>                  `(progn ,(cdr otherwise-clause))
>
> -- 
> Masayuki Onjo <onjo at lispuser.net>

--
Marco Antoniotti


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cl-unification-devel/attachments/20070418/ff09d62e/attachment.html>


More information about the cl-unification-devel mailing list