[m-dev.] Here's an idea.

Tyson Richard DOWD trd at cs.mu.oz.au
Fri Sep 5 14:15:50 AEST 1997


Fergus Henderson wrote:
> 
> It would work OK if you use import_module rather than use_module,
> but then you have the problem that [1,2,3] is ambiguous.

This probably isn't a huge problem, but it's not very nice.

> 
> Another alternative would be to overload some unary prefix operator, e.g. ~,
> or perhaps +, to mean the same as univ/1 (which is the function version of
> type_to_univ/2).  Then you could write
> 
>  	sprintf("%d %d %f %s\n", [~3, ~4, ~2.5, ~"foo"], Str) 
> 
> This avoids overloading `.', so it might be preferable.

It's not too bad, but it's still a bit yuck.
Another solution (that is also a little yuck) is to overload ,/2, so you
can do:
  	sprintf("%d %d %f %s\n", (3, 4, 2.5, "foo", []), Str) 

> However, this still doesn't solve one of the main problems of formatted
> I/O, namely extensibility.  I think that if we are going to extend the
> current formatted I/O support, we should look for a solution using type
> classes that can provide formatted I/O for values of user-defined types.

Sure, but even a typeclasses based solution would benefit from a neat way
of writing heterogenous lists. Unless you have in mind another method...

-- 
       Tyson Dowd           #          Another great idea from the 
                            #            people who brought you
      trd at .cs.mu.oz.au      #               Beer Milkshakes!
http://www.cs.mu.oz.au/~trd #	         Confidence --- Red Dwarf



More information about the developers mailing list