March 03, 2003
"Dan Liebgold" <Dan_member@pathlink.com> wrote in message news:b40jlg$27to$1@digitaldaemon.com...
> In article <b40d29$23a9$1@digitaldaemon.com>, Walter says...
> >But C++ supports covariant function return types. Or is something broken about it that I'm missing? Oddly, C# does not support it, nor does Java.
I'd
> >intended to make this work in D for a while, I just was buried in other things. I've been looking at adding 'virtual types', too.
> Hmmm, I guess they slipped that in to the C++ design when I wasn't
looking. Do
> you know when it was added?  It seems to have been discussed as recently
as a
> few years ago.

I don't know when it was added, but it's in the C++98 spec.


March 03, 2003
"Garen" <garen_nospam_@wsu.edu> wrote in message news:b40jpp$280e$1@digitaldaemon.com...
> Walter wrote:
> > But C++ supports covariant function return types. Or is something broken about it that I'm missing? Oddly, C# does not support it, nor does Java.
I'd
> > intended to make this work in D for a while, I just was buried in other things. I've been looking at adding 'virtual types', too.
> Both C# and Java plan to have 'em in future releases.

I'll  update www.digitalmars.com/d/comparsion.html whenver they do. D has it now.

> How would virtual types fit in with templates?

VT's are more a feature of classes, not templates.


March 03, 2003
"Dan Liebgold" <Dan_member@pathlink.com> wrote in message news:b40ko4$28l7$1@digitaldaemon.com...
> Are there plans to support initializing arrays with function literals,
like
> this:
>
> //------------------------------------------------//
> typedef void function (char*) print_proc;
>
> print_proc functbl[4] = [
> (print_proc)function void (char * text) { printf(" %s,\n", text); },
> (print_proc)function void (char * text) { printf(" [%s],\n", text); },
> (print_proc)function void (char * text) { printf("%s,\n", text); },
> (print_proc)function void (char * text) { printf(" {%s},\n", text); },
> ];
>
> void test () {
> for (int i = 0; i < tbl.length; ++i)
> functbl[i]("nonsense");
> }
> //------------------------------------------------//
>
> Currently, the compiler complains with "non-constant expression
__anonymous".
> Perhaps its the above code has an error?

Looks like a compiler bug.

> This will work if I separate out the definitions of the functions and name
them,
> then put the names in the array.


March 03, 2003
"Walter" <walter@digitalmars.com> escreveu na mensagem news:b40d29$23a9$1@digitaldaemon.com...
>
> "Dan Liebgold" <Dan_member@pathlink.com> wrote in message news:b40b5v$21pv$1@digitaldaemon.com...
> > " Added covariant function return types."
> >
> > Very cool!  Yet another thing that is just plain broken in C++, fixed in
> D.
>
> But C++ supports covariant function return types. Or is something broken about it that I'm missing? Oddly, C# does not support it, nor does Java.
I'd
> intended to make this work in D for a while, I just was buried in other things. I've been looking at adding 'virtual types', too.
>
By virtual types do you mean Beta like virtual classes? http://www.mjolner.com/mjolner-system/documentation/beta-intro/


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.459 / Virus Database: 258 - Release Date: 25/2/2003


March 04, 2003
This one must be long-standing:

   void main()
   {
   }

This program, when compiled, returns 1244984 - I was hoping for zero. If this isn't a well-formed main (which I do want it to be), I'd like for it to be erroneous.  Also:

   float main(real x)
   {
      return 0;
   }

Yeah, it links.

March 04, 2003
"Daniel Yokomiso" <daniel_yokomiso@yahoo.com.br> wrote in message news:b40pqk$2c3e$1@digitaldaemon.com...
> "Walter" <walter@digitalmars.com> escreveu na mensagem
> > I've been looking at adding 'virtual types', too.
> >
> By virtual types do you mean Beta like virtual classes? http://www.mjolner.com/mjolner-system/documentation/beta-intro/

I don't understand Beta at all.


March 04, 2003
"Walter" <walter@digitalmars.com> escreveu na mensagem news:b411ej$2gpo$1@digitaldaemon.com...
>
> "Daniel Yokomiso" <daniel_yokomiso@yahoo.com.br> wrote in message news:b40pqk$2c3e$1@digitaldaemon.com...
> > "Walter" <walter@digitalmars.com> escreveu na mensagem
> > > I've been looking at adding 'virtual types', too.
> > >
> > By virtual types do you mean Beta like virtual classes? http://www.mjolner.com/mjolner-system/documentation/beta-intro/
>
> I don't understand Beta at all.
>

There's a good paper about virtual types and genericity in Beta:

http://citeseer.nj.nec.com/thorup99unifying.html

What'll be virtual types in D?



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.459 / Virus Database: 258 - Release Date: 26/2/2003


March 04, 2003
"Walter" <walter@digitalmars.com> wrote in news:b3vdgg$1f8t$1 @digitaldaemon.com:

> Maintenance.
> 
> www.digitalmars.com/d/changelog.html

Value of v is wrong in the following code.
Seems the stack indexing for delegates
isn't quite right yet.


alias bit delegate(int) callback;


bit foo(callback a)
{

  return a(12);
}

class Bar
{

  int func(int v)
  {
    foo(delegate bit(int a) { printf("%d %d\n",a,v); return true; } );

    return v;
  }
}


int main(char[][] argv)
{
  Bar b = new Bar();

  b.func(15);
  return 0;
}


March 04, 2003
"Daniel Yokomiso" <daniel_yokomiso@yahoo.com.br> wrote in message news:b415t0$2j23$1@digitaldaemon.com...
> There's a good paper about virtual types and genericity in Beta:
>
> http://citeseer.nj.nec.com/thorup99unifying.html
>
> What'll be virtual types in D?

That's a good paper. I'll have to study it first.


March 04, 2003

Daniel Yokomiso wrote:
> "Walter" <walter@digitalmars.com> escreveu na mensagem
> news:b411ej$2gpo$1@digitaldaemon.com...
> 
>>"Daniel Yokomiso" <daniel_yokomiso@yahoo.com.br> wrote in message
>>news:b40pqk$2c3e$1@digitaldaemon.com...
>>
>>>"Walter" <walter@digitalmars.com> escreveu na mensagem
>>>
>>>>I've been looking at adding 'virtual types', too.
>>>>
>>>
>>>By virtual types do you mean Beta like virtual classes?
>>>http://www.mjolner.com/mjolner-system/documentation/beta-intro/
>>
>>I don't understand Beta at all.
>>
> 
> 
> There's a good paper about virtual types and genericity in Beta:
> 
> http://citeseer.nj.nec.com/thorup99unifying.html
> 
> What'll be virtual types in D?
> 
> 
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.459 / Virus Database: 258 - Release Date: 26/2/2003
> 
> 

Hi, Daniel.

I read most of the paper you listed.  Yep.  Those are virtual types, and they provide a powerful programming capability.  One major problem I have with the version of virtual types described in the paper is that I will probably fail in getting my team to use them.  Look at how long and hard to understand the paper is.  It's not the author's fault, it's simply a difficult subject.  The other major issue I have with them is they look really hard to implement.

An even more powerfull capability can be found in Sather, although it doesn't have the static type checking capability.  It's called "include" in that language.  The "include" construct seems easy to understand and use, and it is very easy to implement.

Here's a URL to the manual page on the "include" construct.

http://www.icsi.berkeley.edu/~sather/Documentation/LanguageDescription/webmaker/DescriptionX2Erem-chapters-1.html#HEADING1-2

I think the lack of static type checking makes it more powerful, not less.  For example, with the include construct, I can apply a module's functionality to all kinds of other modules, even though they don't in any way inherit from anything that the original module knows about. That's the way it should be.  You can also apply a module's functionality multiple times to other modules, without any multiple-inheritance kinds of crud in the compiler or generated code.

Another nice advantage of the "include" construct is that it allows us to reuse any code, not just template code.  You don't have to rely on a programmer having 20/20 foresight and providing exactly correct template wrappers in order for you to reuse his code.  Everything is a template.

Perl has some difficult to understand features.  However, I've never seen a single one get used, and I've read a lot of Perl code.  It also has very very many simple features that get used all the time (too often in my opinion).  I think that's a major part of Perl's success.

I'm putting in a vote for the simple version of virtual types (Sather's "include" construct).  The KISS rule is rarely wrong.

Bill