November 02, 2006
Walter Bright wrote:

> Major new stuff! But please, let's discuss that over in the digitalmars.D group.
> 
> http://www.digitalmars.com/d/changelog.html
> 
> http://ftp.digitalmars.com/dmd.173.zip

The reference links to "A Deeper Look at Signals and Slots" and "Boost Signals" appear to be broken.

-- 
~John Demme
me@teqdruid.com
http://www.teqdruid.com/
November 02, 2006
John Demme wrote:
> The reference links to "A Deeper Look at Signals and Slots" and "Boost
> Signals" appear to be broken.

Fixed.
November 02, 2006
"Walter Bright" <newshound@digitalmars.com> wrote in message news:eicbn3$2qba$1@digitaldaemon.com...
> Major new stuff! But please, let's discuss that over in the digitalmars.D group.
>
> http://www.digitalmars.com/d/changelog.html
>
> http://ftp.digitalmars.com/dmd.173.zip

Un.  Be.  Liev.  A.  Ble.

Not only are variadic templates _amazing_ things, they're also _exactly_ what I'll need to do the MiniD binding library (and Kirk is understandably happy as well!).


November 02, 2006
"Jarrett Billingsley" <kb3ctd2@yahoo.com> wrote in message news:eidi8o$11o4$2@digitaldaemon.com...
> Un.  Be.  Liev.  A.  Ble.
>
> Not only are variadic templates _amazing_ things, they're also _exactly_ what I'll need to do the MiniD binding library (and Kirk is understandably happy as well!).

Waaahaha!  This is so cool.  A variadic "call" function for MiniD which used to look like:

public void easyCall(MDClosure func, uint numReturns, ...)
 {
  uint funcReg = push(func);

  for(int i = 0; i < _arguments.length; i++)
  {
   TypeInfo ti = _arguments[i];

   if(ti == typeid(bool))
push(cast(bool)va_arg!(bool)(_argptr));
   else if(ti == typeid(byte))        push(cast(int)va_arg!(byte)(_argptr));
   else if(ti == typeid(ubyte))
push(cast(int)va_arg!(ubyte)(_argptr));
   else if(ti == typeid(short))
push(cast(int)va_arg!(ushort)(_argptr));
   else if(ti == typeid(ushort))
push(cast(int)va_arg!(ushort)(_argptr));
   else if(ti == typeid(int))         push(cast(int)va_arg!(int)(_argptr));
   else if(ti == typeid(uint))        push(cast(int)va_arg!(uint)(_argptr));
   else if(ti == typeid(long))        push(cast(int)va_arg!(long)(_argptr));
   else if(ti == typeid(ulong))
push(cast(int)va_arg!(ulong)(_argptr));
   else if(ti == typeid(float))
push(cast(float)va_arg!(float)(_argptr));
   else if(ti == typeid(double))
push(cast(float)va_arg!(double)(_argptr));
   else if(ti == typeid(real))
push(cast(float)va_arg!(real)(_argptr));
   else if(ti == typeid(char[]))      push(new
MDString(va_arg!(char[])(_argptr)));
   else if(ti == typeid(wchar[]))     push(new
MDString(va_arg!(wchar[])(_argptr)));
   else if(ti == typeid(dchar[]))     push(new
MDString(va_arg!(dchar[])(_argptr)));
   else if(ti == typeid(MDObject))
push(cast(MDObject)va_arg!(MDObject)(_argptr));
   else if(ti == typeid(MDUserdata))
push(cast(MDUserdata)va_arg!(MDUserdata)(_argptr));
   else if(ti == typeid(MDClosure))
push(cast(MDClosure)va_arg!(MDClosure)(_argptr));
   else if(ti == typeid(MDTable))
push(cast(MDTable)va_arg!(MDTable)(_argptr));
   else if(ti == typeid(MDArray))
push(cast(MDArray)va_arg!(MDArray)(_argptr));
   else throw new MDRuntimeException(this, "MDState.easyCall(): invalid
parameter ", i);
  }

  call(funcReg, _arguments.length, numReturns);
 }

Has now become:

public void easyCall(T...)(MDClosure func, uint numReturns, T params)
{
 uint funcReg = push(func);

 foreach(param; params)
  push(param);

 call(funcReg, params.length, numReturns);
}

Not only is it magnitudes easier to read, it's also far more efficient.

Amazing, amazing, amazing.  Thank you so much, again and again.


November 02, 2006
Walter Bright wrote:
> Major new stuff! But please, let's discuss that over in the digitalmars.D group.
> 
> http://www.digitalmars.com/d/changelog.html
> 
> http://ftp.digitalmars.com/dmd.173.zip

Excellent! I would love to check out the Signal and Slot implementation. Too bad I am tied up in other projects using other languages.

Bastiaan.
November 02, 2006
Bastiaan Veelo wrote:
> Too bad I am tied up in other projects using other languages.

Resistance is futile.
November 03, 2006
Walter Bright wrote:
> Major new stuff! But please, let's discuss that over in the digitalmars.D group.
> 
> http://www.digitalmars.com/d/changelog.html
> 
> http://ftp.digitalmars.com/dmd.173.zip

Variadic templates, and tuples... badass.
November 03, 2006
Jarrett Billingsley wrote:
> "Jarrett Billingsley" <kb3ctd2@yahoo.com> wrote in message news:eidi8o$11o4$2@digitaldaemon.com...
> 
>>Un.  Be.  Liev.  A.  Ble.
>>
>>Not only are variadic templates _amazing_ things, they're also _exactly_ what I'll need to do the MiniD binding library (and Kirk is understandably happy as well!).
> 
> 
> Waaahaha!  This is so cool.  A variadic "call" function for MiniD which used to look like:
> 
> public void easyCall(MDClosure func, uint numReturns, ...)
>  {
>   uint funcReg = push(func);
> 
>   for(int i = 0; i < _arguments.length; i++)
>   {
>    TypeInfo ti = _arguments[i];
> 
>    if(ti == typeid(bool)) push(cast(bool)va_arg!(bool)(_argptr));
>    else if(ti == typeid(byte))        push(cast(int)va_arg!(byte)(_argptr));
>    else if(ti == typeid(ubyte)) push(cast(int)va_arg!(ubyte)(_argptr));
>    else if(ti == typeid(short)) push(cast(int)va_arg!(ushort)(_argptr));
>    else if(ti == typeid(ushort)) push(cast(int)va_arg!(ushort)(_argptr));
>    else if(ti == typeid(int))         push(cast(int)va_arg!(int)(_argptr));
>    else if(ti == typeid(uint))        push(cast(int)va_arg!(uint)(_argptr));
>    else if(ti == typeid(long))        push(cast(int)va_arg!(long)(_argptr));
>    else if(ti == typeid(ulong)) push(cast(int)va_arg!(ulong)(_argptr));
>    else if(ti == typeid(float)) push(cast(float)va_arg!(float)(_argptr));
>    else if(ti == typeid(double)) push(cast(float)va_arg!(double)(_argptr));
>    else if(ti == typeid(real)) push(cast(float)va_arg!(real)(_argptr));
>    else if(ti == typeid(char[]))      push(new MDString(va_arg!(char[])(_argptr)));
>    else if(ti == typeid(wchar[]))     push(new MDString(va_arg!(wchar[])(_argptr)));
>    else if(ti == typeid(dchar[]))     push(new MDString(va_arg!(dchar[])(_argptr)));
>    else if(ti == typeid(MDObject)) push(cast(MDObject)va_arg!(MDObject)(_argptr));
>    else if(ti == typeid(MDUserdata)) push(cast(MDUserdata)va_arg!(MDUserdata)(_argptr));
>    else if(ti == typeid(MDClosure)) push(cast(MDClosure)va_arg!(MDClosure)(_argptr));
>    else if(ti == typeid(MDTable)) push(cast(MDTable)va_arg!(MDTable)(_argptr));
>    else if(ti == typeid(MDArray)) push(cast(MDArray)va_arg!(MDArray)(_argptr));
>    else throw new MDRuntimeException(this, "MDState.easyCall(): invalid parameter ", i);
>   }
> 
>   call(funcReg, _arguments.length, numReturns);
>  }
> 
> Has now become:
> 
> public void easyCall(T...)(MDClosure func, uint numReturns, T params)
> {
>  uint funcReg = push(func);
> 
>  foreach(param; params)
>   push(param);
> 
>  call(funcReg, params.length, numReturns);
> }
> 
> Not only is it magnitudes easier to read, it's also far more efficient.
> 
> Amazing, amazing, amazing.  Thank you so much, again and again. 
> 
> 

That has to be about as significant an example as one could ask for.  Also, the new code makes it much more future-compatable, as it can be made ready for new datatypes without ever editing easyCall itself!  (So long as push() supports the type, you're good to go.)

-- Chris Nicholson-Sauls
November 03, 2006
Walter Bright wrote:
> Major new stuff! But please, let's discuss that over in the digitalmars.D group.
> 
> http://www.digitalmars.com/d/changelog.html

One of the 'minor things' is also

"Template instantiations can now accept alias parameters for local variables and nested functions."

which is of great interest to me, since now meta.prettynameof!() can work with local variables; this will be significant for DDL and probably things like PyD as well.
But, the name mangling is really weird. It's totally different to the name mangling for static variables, for example.

Maybe this is intentional, and needs to be that way; but it's a bit tricky to parse, so I'd like confirmation that it's not a mistake.

Below is an example, taken from my meta.nameof file.

-----------
    template inner(alias F)
    {
      class inner { }
    }
    template outer(alias B)
    {
      void function( inner!(B) ) outer;
    }
    template rawmanglednameof(alias A)
    {
      const char [] rawmanglednameof  =
                 typeof(&outer!(A)).mangleof;
    }

void wolf() {
       static int proto;
       int quark;

       static assert(rawmanglednameof!(proto)==
       "PPFC"
       ~ "4meta6nameof42__T5inner"
       ~ "S29_D4meta6nameof4wolfFZv"
       ~ "5protoi"
       ~ "Z5innerZv");

        static assert(rawmanglednameof!(quark)==
        "PPFC"

        ~ "_D4meta6nameof4wolfFZv54__T16rawmanglednameof"
        ~ "S29_D4meta6nameof4wolfFZv5quarkiZ42__T5outer"
        ~ "S29_D4meta6nameof4wolfFZv5quarkiZ42__T5inner"

        ~ "S29_D4meta6nameof4wolfFZv"
        ~ "5quarki"
        ~ "Z5innerZv");

/* Why isn't it just:
      "PPFC"
       ~ "4meta6nameof42__T5inner"
       ~ "S29_D4meta6nameof4wolfFZv"
       ~ "5quarki"
       ~ "Z5innerZv"
?
*/
}
November 03, 2006
Don Clugston wrote:
> "Template instantiations can now accept alias parameters for local variables and nested functions."
> 
> which is of great interest to me, since now meta.prettynameof!() can work with local variables; this will be significant for DDL and probably things like PyD as well.
> But, the name mangling is really weird. It's totally different to the name mangling for static variables, for example.

What happens is when one of the parameters is an alias to a local, the template becomes a *nested* class/function, and is mangled like one.
1 2 3 4
Top | Discussion index | About this forum | D home