Thread overview
std.boxer type query
Aug 29, 2005
Derek Parnell
Aug 29, 2005
David L. Davis
Aug 29, 2005
David L. Davis
Aug 30, 2005
Derek Parnell
Sep 02, 2005
Burton Radons
Sep 03, 2005
David L. Davis
August 29, 2005
I'm having a mental block and for the life of me a cannot work out how to code a simple and efficient test for the data type of a Box.

I want to do this sort of thing ...

  Box foo;
  . . .
  if (foo.type == dchar[])
  {
    . . .
  }

Help!

-- 
Derek Parnell
Melbourne, Australia
30/08/2005 2:22:53 AM
August 29, 2005
In article <1fv0hytva73p0.13560ith3id22.dlg@40tude.net>, Derek Parnell says...
>
>I'm having a mental block and for the life of me a cannot work out how to code a simple and efficient test for the data type of a Box.
>
>I want to do this sort of thing ...
>
>  Box foo;
>  . . .
>  if (foo.type == dchar[])
>  {
>    . . .
>  }
>
>Help!
>
>-- 
>Derek Parnell
>Melbourne, Australia
>30/08/2005 2:22:53 AM

Derek,

I hope you find this example code useful:

# // boxtype.d
# private import std.stdio;
# private import std.boxer;
#
# int main()
# {
#     Box foo = box("This is a test!"d);
#
#     // ...
#     if (foo.type() == typeid(dchar[]))
#         writefln("dchar[] value=%s", unbox!(dchar[])(foo));
#     else
#         writefln(" not a dchar[] value");
#
#     return 0;
# }

Output:
-------
C:\dmd>dmd boxtype.d -release
C:\dmd\bin\..\..\dm\bin\link.exe boxtype,,,user32+kernel32/noi;

C:\dmd>boxtype
dchar[] value=This is a test!

C:\dmd>

David L.

-------------------------------------------------------------------
"Dare to reach for the Stars...Dare to Dream, Build, and Achieve!"
-------------------------------------------------------------------

MKoD: http://spottedtiger.tripod.com/D_Language/D_Main_XP.html
August 29, 2005
In article <1fv0hytva73p0.13560ith3id22.dlg@40tude.net>, Derek Parnell says...
>
>I'm having a mental block and for the life of me a cannot work out how to code a simple and efficient test for the data type of a Box.
>
>I want to do this sort of thing ...
>
>  Box foo;
>  . . .
>  if (foo.type == dchar[])
>  {
>    . . .
>  }
>
>Help!
>
>-- 
>Derek Parnell
>Melbourne, Australia
>30/08/2005 2:22:53 AM

Opps!

Line: if (foo.type() == typeid(dchar[]))
should be: if (foo.type() is typeid(dchar[]))

You may find some other useful code from my Box-Xtras section of my site: http://spottedtiger.tripod.com/D_Language/D_BoxXtras_Support_Projects_XP.html

David L.

-------------------------------------------------------------------
"Dare to reach for the Stars...Dare to Dream, Build, and Achieve!"
-------------------------------------------------------------------

MKoD: http://spottedtiger.tripod.com/D_Language/D_Main_XP.html
August 30, 2005
On Mon, 29 Aug 2005 17:25:47 +0000 (UTC), David L. Davis wrote:

> In article <1fv0hytva73p0.13560ith3id22.dlg@40tude.net>, Derek Parnell says...
>>
>>I'm having a mental block and for the life of me a cannot work out how to code a simple and efficient test for the data type of a Box.
>>
>>I want to do this sort of thing ...
>>
>>  Box foo;
>>  . . .
>>  if (foo.type == dchar[])
>>  {
>>    . . .
>>  }
>>
>>Help!
>>
>>-- 
>>Derek Parnell
>>Melbourne, Australia
>>30/08/2005 2:22:53 AM
> 
> Opps!
> 
> Line: if (foo.type() == typeid(dchar[]))
> should be: if (foo.type() is typeid(dchar[]))

Thanks. I forgot about 'typeid()'. This is my first play with boxes. A pity about the -release restriction. I also found out that you must not have -unittest either.

> You may find some other useful code from my Box-Xtras section of my site: http://spottedtiger.tripod.com/D_Language/D_BoxXtras_Support_Projects_XP.html

Thanks. I'll have a peek or two.

-- 
Derek Parnell
Melbourne, Australia
30/08/2005 10:14:47 PM
September 02, 2005
Derek Parnell wrote:
> On Mon, 29 Aug 2005 17:25:47 +0000 (UTC), David L. Davis wrote:
> 
> 
>>In article <1fv0hytva73p0.13560ith3id22.dlg@40tude.net>, Derek Parnell says...
>>
>>>I'm having a mental block and for the life of me a cannot work out how to
>>>code a simple and efficient test for the data type of a Box.
>>>
>>>I want to do this sort of thing ...
>>>
>>> Box foo;
>>> . . .
>>> if (foo.type == dchar[])
>>> {
>>>   . . . }
>>>
>>>Help!
>>>
>>>-- 
>>>Derek Parnell
>>>Melbourne, Australia
>>>30/08/2005 2:22:53 AM
>>
>>Opps!
>>
>>Line: if (foo.type() == typeid(dchar[]))
>>should be: if (foo.type() is typeid(dchar[]))
> 
> 
> Thanks. I forgot about 'typeid()'. This is my first play with boxes. A pity
> about the -release restriction. I also found out that you must not have
> -unittest either.

You can get around this restriction without recompiling Phobos by putting "extern (C) void assert_3std5boxer () { }" in your code. Hopefully this will be one of the fixes in 0.130.
September 03, 2005
In article <df90su$30te$1@digitaldaemon.com>, Burton Radons says...
>
>Derek Parnell wrote:
>> On Mon, 29 Aug 2005 17:25:47 +0000 (UTC), David L. Davis wrote:
>> 
>> 
>>>In article <1fv0hytva73p0.13560ith3id22.dlg@40tude.net>, Derek Parnell says...
>>>
>>>>I'm having a mental block and for the life of me a cannot work out how to code a simple and efficient test for the data type of a Box.
>>>>
>>>>I want to do this sort of thing ...
>>>>
>>>> Box foo;
>>>> . . .
>>>> if (foo.type == dchar[])
>>>> {
>>>>   . . .
>>>> }
>>>>
>>>>Help!
>>>>
>>>>-- 
>>>>Derek Parnell
>>>>Melbourne, Australia
>>>>30/08/2005 2:22:53 AM
>>>
>>>Opps!
>>>
>>>Line: if (foo.type() == typeid(dchar[]))
>>>should be: if (foo.type() is typeid(dchar[]))
>> 
>> 
>> Thanks. I forgot about 'typeid()'. This is my first play with boxes. A pity about the -release restriction. I also found out that you must not have -unittest either.
>
>You can get around this restriction without recompiling Phobos by putting "extern (C) void assert_3std5boxer () { }" in your code. Hopefully this will be one of the fixes in 0.130.

Thanks Burton!! :) It's very helpful.

David L.

-------------------------------------------------------------------
"Dare to reach for the Stars...Dare to Dream, Build, and Achieve!"
-------------------------------------------------------------------

MKoD: http://spottedtiger.tripod.com/D_Language/D_Main_XP.html