Polysemous Values Qustion

Christopher Wright dhasenan at gmail.com
Tue Sep 25 16:02:51 PDT 2007


Janice Caron wrote:
> In another thread, Christopher Wright said that polysemous meant "A
> variable that can have several types depending on how it is assigned
> or casted is polysemous. Walter wants to use this especially for
> string literals -- should it be fixed length or not, should it be
> char, wchar,
> dchar?"
> 
> And then Don Clugston said "For example, the literal number 1. Could
> be a short, int, uint, float, complex number,..."
> 
> Both of those examples are LITERALS. I get that. Literal can be
> interpreted as either one type or another. It makes sense that you'd
> want to delay nailing down the decision until you really have to.
> 
> But CW said: "A /variable/..." (my emphasis). Can you have a
> polysemous variable (as opposed to literal)? I don't get how that
> would work.

I believe polysemy will have to be resolved at compile time. Walter 
would know better. So, if your variable is subjected to constant 
expansion, *maybe* Walter will allow it to be polysemous via the auto 
keyword. But that would likely be a fair bit harder than forcing typing 
at first use -- the assignment.

If Walter's reading this, he's probably thinking that it's a bad idea to 
allow any type to be unresolved for very long, given the problems people 
have mentioned. And if not, well, that might be reason enough for me to 
stick with D2 rather than going with D3. (I hate, hate, HATE languages 
where it's nontrivial to tell the effective type of something.)

Chris Wright.



More information about the Digitalmars-d mailing list