Printing shortest decimal form of floating point number with Mir

welkam wwwelkam at gmail.com
Tue Jan 5 15:04:34 UTC 2021


On Monday, 4 January 2021 at 22:55:28 UTC, Ola Fosheim Grøstad 
wrote:
> It is a name, e.g.:
>
> alias BarInt = Bar!int;
>
>
> "BarInt", "Bar!int" and "Foo!int" are all names, or labels, if 
> you wish. And they all refer to the same object: the nominal 
> type. Which you can test easily by using "is(BarInt==Foo!int)".

Bar!int is not a name. It's declaration. Bar is the name.
https://github.com/dlang/dmd/blob/master/src/dmd/dtemplate.d#L5754

Labels are myLabel: and are used with goto, break, continue.

Objects are class instances.

On Monday, 4 January 2021 at 23:08:31 UTC, Ola Fosheim Grøstad 
wrote:
> If the terminology is difficult, <...>

The main problem here is that you use words/definitions 
interchangeably that refer to similar concepts but are different. 
As if they are the same. They are not! I got the concept from the 
first post and I believe most here got it too. What we have 
trouble here is getting it from abstract realm to reality. And 
reality demands it to be specific.

> <other names> and type "struct _ {}" <...> should be 
> interchangeable with no semantic impact.

What you want is to reference template thingy by name and assign 
it to thing so when you use the thing it should be 
interchangeable with template thingy and should be semantically 
equivalent. So what is a thing? From your posts its either/or:
1. identifier
2. declaration.

And from your posts the template thingy is either/or:
1. template instantiation
2. template definition

Since you cant get specific we will talk about all 4 
possibilities. For a template declaration of myStruct lets see 
how we can go about creating an alias to it.

struct myStruct(T) {}

For assigning template instantiation to a identifier(1,1) its 
simple.
alias myS11 = myStruct!int;

For assigning template definition to a identifier(1,2) you write 
like this
alias myS12 = myStruct;

For assigning template instantiation to a declaration(2,1) well 
you cant. The language does not permit that.

For assigning template definition to a declaration(2,2). You cant 
do that too.

And in practice it looks like this
[code]
struct myStruct(T) {}
void f(T)(myStruct!T x) {}

void main()
{
     alias myS11 = myStruct!int;
     alias myS12 = myStruct;
    	
     myStruct!int x;
     f(x);

     myS11 x11;
     f(x11);

     myS12!int x12;
     f(x12);	
}
[/code]

Now there are also function templates but I will leave it as 
homework assignment. So the million dollar question is. What do 
you want to do with alias assignment to declaration that you cant 
do by assignment to identifier?


> Drop ad hominem. Argue the case.

Ad hominem is when you use insult INSTEAD of argument. A detail 
that most people miss. Also how "i'm like you" is an insult?



More information about the Digitalmars-d-announce mailing list