On Tue, 2007-03-27 at 09:33 -0700, Erick Tryzelaar wrote:
> skaller wrote:
> > On Sat, 2007-03-24 at 16:54 -0700, Erick Tryzelaar wrote:
> >> Currently if you have a formatting string f"%s", it expects a charp
> >> instead of a string. To get the string, you need f"%S". Since I'd expect
> >> that felix strings will be used much more often than charps, mind if I
> >> swap the two meanings?
> >
> > The main reason for %s being a charp (char *) is that this is the
> > C meaning.
>
> Oh I know, but since I expect felix strings would be used more often
> than charps, swapping the meaning might make a little more sense to
> someone new to the language. I realize that this is all just getting
> passed to vsnprintf, but we could change the string on our side to make
> it how we like it.
yes, we could, but it is easier and more consistent to ADD a new
format character %S for strings, than have to explain that %s
means strings and %s is for charps.
> >> Also, once we roll out the show typeclass, we probably should replace
> >> "%s" with a call to Show::str, so that "%s" can be used for most types.
> >
> > Actually that won't work with the current model I don't think.
> > The reason is that
> >
> > f"%s"
> >
> > is actually a FUNCTION, not a piece of data:
> >
> > f"%s": charp -> string
> > f"%d": int -> string
> >
> > and in particular it's a closure .. Felix doesn't allow
> > closures over polymorphic functions. (But I'm not sure,
> > perhaps it will work if the closure is never formed,
> > as for other polymorphic functions).
>
> I assume that includes functions using typeclasses to restrict the
> polymorphism?
if you want you can always do
fun fmt[t with Show[t]] (x:t) => f"Value=%S" (str x);
where str is a virtual of show. This is polymorphic and applies
str to the argument.
--
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language