From: Michael Lenaghan <[email protected]> Subject: Re: [r6rs-discuss] What's under the hood? Date: Wed, 23 Sep 2009 22:29:33 -0400
> we'd be talking about introducing one: > > (define-vector-type <name> <type>) > > Now the above 8 primitives become derived. But--much more > importantly--so do boolean vectors and floating point vectors and > vectors of shape objects. > > A naive compiler would perhaps just implement all of this in terms of > vectors (with a type tag). And a naive compiler would still be free to > implement strings and u8 vectors differently as long as they honored > the contract. A smart compiler, on the other hand, could work some > time and space magic. Could you specify a bit more about what information <type> should carry? I suspect that, to give enough information to allow "a smart compiler" to work with this definition, you need a structured way to define and construct types, including specifying allowed value ranges and possible coercion rules. It is interesting path to go, but I think resulting language would be much more type-centric than existing Scheme. If you don't put enough information in <type>, then each smart compiler need to work out the characteristics of each type by its own, and define-vector-type doesn't help much here. It only benefits naive implementations, in which type-specific APIs are trivially generated even from underspecified define-vector-types. Besides, the similarity of strings and vectors are superficial; both are fixed length and has -ref and -set! in RnRS, but the usage pattern and the nature of their elements are very different, so their implementations tend to differ a lot. How do you express those difference in define-vector-type? If you don't, then again, define-vector-type is useless for any implementation that wants to be a bit smarter than naive implementation where it just uses a ucs4 array as a string. --shiro _______________________________________________ r6rs-discuss mailing list [email protected] http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss
