[bitc-dev] Opinions wanted: Infix shift operators
wren ng thornton
wren at freegeek.org
Thu Aug 5 12:13:01 PDT 2010
Elias Gabriel Amaral da Silva wrote:
> 2010/7/28 Jonathan S. Shapiro <shap at eros-os.org>:
>> The problem at heart is that BitC doesn't have variadic procedures, and
>> therefore cannot implement printf(). My intention above was to propose a
>> typable mechanism for stream "forwarding" where multiple objects are to be
>> emitted. From our phone call, your concern is less about this syntax than
>> about the horrible state conflation in the C++ IOStreams model (e.g.
>> std::hex). I agree with you about that concern, but that's simply a case of
>> a badly designed interface; it has little to do with this choice of syntax.
>> Just as one possible alternative, replace C++:
>
> You probably know about ocaml and haskell hacks to implement printf.
> Don't you like it? OCaml's, is particularly interesting, because it
> doesn't involve run-time checking of the types (with a small penalty
> of having to define the format string statically)
If you have type classes, then you have variadic functions[1]. Oleg
Kiselyov, Chung-chieh Shan, myself, and Paczesiowa have each shown this
in different ways depending on the other language features we've allowed
ourselves to use. MPTCs + UndecidableInstances seems to be all that's
required, though fundeps help remove a lot of boilerplate. You may be
able to get rid of MPTCs if you allow OverlappingInstances and
FlexibleInstances; I haven't tried it yet.
Whichever poison you pick, I'm pretty sure you already have enough rope
in BitC. The only thing special about printf is that static typechecking
requires dependent types (or shenanigans with overloading the string
literal syntax).
[1] And other non-regular types like ((Int->)^n ([]^n e)-> e) or
(((a->)^n r) -> ([a]->)^n r)
--
Live well,
~wren
More information about the bitc-dev
mailing list