Opened 7 years ago
Last modified 7 years ago
#1445 new enhancement
Support parameterised hash table type declarations
Reported by: | evhan | Owned by: | |
---|---|---|---|
Priority: | not urgent at all | Milestone: | someday |
Component: | scrutinizer | Version: | 5.0.0 |
Keywords: | scrutiniser, srfi-69 | Cc: | |
Estimated difficulty: | medium |
Description
As suggested by megane on chicken-hackers.
Support specifying the types of hash table keys and values:
(define t (the (hash-table fixnum symbol) ...)) (hash-table-ref t 'foo) ; warning "expected argument #2 of type `fixnum' but was given an argument of type `symbol'" (hash-table-ref t 42) ; result would be known to be a symbol
And so on.
Attachments (3)
Change History (6)
comment:1 Changed 7 years ago by
Component: | unknown → scrutinizer |
---|---|
Estimated difficulty: | → medium |
Changed 7 years ago by
Attachment: | parameterized-struct-type-style-2.patch added |
---|
Changed 7 years ago by
Attachment: | example.scm added |
---|
comment:2 Changed 7 years ago by
- (struct foo #f) == (struct foo)
- (struct foo (* ...)) is simplified into (struct foo)
- (struct foo #f) matches with (struct foo any-list)
- If A and B are lists, then (struct foo A) and (struct foo B) only match if (= (length A) (length B)) and all the elements of A and B match.
comment:3 Changed 7 years ago by
Here's another prototype.
These stay same:
- (struct foo #f) == (struct foo)
- (struct foo #f) matches with (struct foo any-list)
- If A and B are lists, then (struct foo A) and (struct foo B) only match if (= (length A) (length B)) and all the elements of A and B match.
New things
- does not simplify (struct foo (* * ...))
- smashes (struct foo (A B ...)) into (struct foo (* * ...))
I think hash-table-set! cannot be #:clean. For example vector-set! is not. So you cannot get key/value related type warnings from setters, unless -strict-types is used.
Changed 7 years ago by
Attachment: | parameterized-struct-type-version3-with-smashing.patch added |
---|
Note: See
TracTickets for help on using
tickets.