www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - std.boxer type query

reply Derek Parnell <derek psych.ward> writes:
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
Aug 29 2005
next sibling parent David L. Davis <SpottedTiger yahoo.com> writes:
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
Aug 29 2005
prev sibling parent reply David L. Davis <SpottedTiger yahoo.com> writes:
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
Aug 29 2005
parent reply Derek Parnell <derek psych.ward> writes:
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
Aug 30 2005
parent reply Burton Radons <burton-radons smocky.com> writes:
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.
Sep 02 2005
parent David L. Davis <SpottedTiger yahoo.com> writes:
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
Sep 02 2005