coalton icon indicating copy to clipboard operation
coalton copied to clipboard

support ifix in pattern matching (draft)

Open jobhdez opened this issue 2 years ago • 1 comments

This is based on this issue https://github.com/coalton-lang/coalton/issues/423.

This is just a draft but I was able to run the example that @eliaslfox provided in the issue.

for example:

CL-USER> (in-package :coalton-user)
#<COMMON-LISP:PACKAGE "COALTON-USER">
COALTON-USER> (coalton-toplevel
		(declare f (IFix -> String))
		(define (f x)
		  (match x
		    (5 "five")
		    (_ "not five"))))
			 
; No value
COALTON-USER> (coalton (f 5))
"five"

Some things I am thinking about is if theres a better way to distinguish the positive fixnums from integers.

I am aware that by doing the length of the integer. but I am still thinking how to distinguish better.

(integer-length most-positive-fixnum)

jobhdez avatar Aug 13 '23 22:08 jobhdez

(deftype bignum () `(and integer (not fixnum)))

Where do we need to take this PR? Any intent on completing it?

stylewarning avatar Jan 31 '24 23:01 stylewarning

this will require a lot more work to get literals appropriately inferred/etc. in a more generic way

stylewarning avatar Mar 26 '24 20:03 stylewarning

my bad. I was going to work on this until my other pr was done. but I havent had much time. But its ok if you closed this. thanks

jobhdez avatar Mar 26 '24 22:03 jobhdez