I have just realized something about literal instantiation that had not
previously occurred to me.
If a literal is passed to a pure procedure, the entire computation is
term substitutable, and therefore can be treated as a literal.
This came up because I was thinking about the implementation of dense
bit sets. We have been working with them a lot over the last few days,
and I was starting to wonder whether we needed to do something about
them in BitC.
But the following seems quite reasonable:
(define (round-up n by)
(let ((n-new (+ n (- by 1))))
(- n-new (mod n-new by))))
round-up: (forall ((IntType 'a)) (pure fn ('a 'a) 'a))
(forall ((sz:word))
(defstruct (BitSet sz)
bits: (array int32 (/ (round-up sz 32:word) 32))))
I do not propose to admit this into the language right now, because it
requires compile-time execution, but knowing that we *could* do this is
rather pleasant.
shap
_______________________________________________
bitc-dev mailing list
[email protected]
http://www.coyotos.org/mailman/listinfo/bitc-dev