Re: Identifying 32 vs 64 bit OS?

2014-08-11 Thread ketmar via Digitalmars-d-learn
On Mon, 11 Aug 2014 05:18:59 + Jeremy DeHaan via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: why do you need that info? D types has well-defined sizes (i.e uint is always 32 bits, and so on). you still can check pointer size -- (void *).sizeof. but i'm pretty sure that you

Re: Identifying 32 vs 64 bit OS?

2014-08-11 Thread Jacob Carlborg via Digitalmars-d-learn
On 11/08/14 07:18, Jeremy DeHaan wrote: I am looking at these versions as described here: http://dlang.org/version.html There are X86 and X86_64 version identifiers, but these specifically mention that they are versions for the processor type. Can they also be used to determine if the OS is

Re: Identifying 32 vs 64 bit OS?

2014-08-11 Thread Freddy via Digitalmars-d-learn
On Monday, 11 August 2014 at 05:19:01 UTC, Jeremy DeHaan wrote: I am looking at these versions as described here: http://dlang.org/version.html There are X86 and X86_64 version identifiers, but these specifically mention that they are versions for the processor type. Can they also be used to

Re: Identifying 32 vs 64 bit OS?

2014-08-11 Thread via Digitalmars-d-learn
On Monday, 11 August 2014 at 07:58:15 UTC, Freddy wrote: If you want to check if the target OS(not your code) is running 32 vs 64 bit you have to do system call for your target OS. Not the OS, but a special CPU instruction: isX86_64() in core.cpuid?

overloads and parents. __traits confusion

2014-08-11 Thread John Colvin via Digitalmars-d-learn
can someone talk me through the reasoning behind this: import std.typetuple; void foo(T)(T v){} void foo(){} version(ThisCompiles) { alias Parent = TypeTuple!(__traits(parent, foo))[0]; pragma(msg, __traits(getOverloads, Parent, foo)); // tuple() } else { alias Parent =

Separate Printing Mantissa and Exponent of a Floating Point

2014-08-11 Thread Nordlöw
Is there a way to separately stringify/print the mantissa and exponent of a floating point? I want this in my pretty-printing module to produce something like 1.2 \cdot 10^3 instead of 1.2e3 I could of course always split on the e but that is kind of non-elegant, I believe.

Re: Using input ranges with std.regex?

2014-08-11 Thread MrSmith via Digitalmars-d-learn
On Wednesday, 25 April 2012 at 21:43:11 UTC, Dmitry Olshansky wrote: On 25.04.2012 23:08, H. S. Teoh wrote: Does std.regex support input ranges to match()? Or do I need to convert to string first? For now, yes you have to convert them. Any random access range of code units should do the

Re: Separate Printing Mantissa and Exponent of a Floating Point

2014-08-11 Thread Nordlöw
Here's my current try: string toMathML(T)(T x) @trusted /** pure */ if (isFloatingPoint!T) { import std.conv: to; import std.algorithm: findSplit; // immutable parts = to!string(x).findSplit(e); if (parts[2].length == 0) return parts[0]; else return parts[0]

Re: Separate Printing Mantissa and Exponent of a Floating Point

2014-08-11 Thread Justin Whear via Digitalmars-d-learn
On Mon, 11 Aug 2014 13:47:13 +, Nordlöw wrote: Is there a way to separately stringify/print the mantissa and exponent of a floating point? I want this in my pretty-printing module to produce something like 1.2 \cdot 10^3 instead of 1.2e3 I could of course always split on the

Re: Separate Printing Mantissa and Exponent of a Floating Point

2014-08-11 Thread Dominikus Dittes Scherkl via Digitalmars-d-learn
On Monday, 11 August 2014 at 14:15:05 UTC, Nordlöw wrote: Here's my current try: string toMathML(T)(T x) @trusted /** pure */ if (isFloatingPoint!T) { import std.conv: to; import std.algorithm: findSplit; // immutable parts = to!string(x).findSplit(e); if (parts[2].length ==

Re: Identifying 32 vs 64 bit OS?

2014-08-11 Thread ketmar via Digitalmars-d-learn
On Mon, 11 Aug 2014 12:51:40 + via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Not the OS, but a special CPU instruction: isX86_64() in core.cpuid? but there is ARM64 coming. and gdc, for example, will has no problems to support it out of the box due to using gcc cogegen.

Linked list as a bidirectional range? I have some questions...

2014-08-11 Thread Gary Willoughby via Digitalmars-d-learn
Just for a bit a fun i've implemented a simple doubly linked list and trying out some range based stuff. Whilst doing so i have some questions which you guys might be able to answer. 1. In your opinion when accessing the elements of a linked list should they yield the data stored within the

Re: Linked list as a bidirectional range? I have some questions...

2014-08-11 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Aug 11, 2014 at 05:51:11PM +, Gary Willoughby via Digitalmars-d-learn wrote: Just for a bit a fun i've implemented a simple doubly linked list and trying out some range based stuff. Whilst doing so i have some questions which you guys might be able to answer. 1. In your opinion

Destroy two assumptions: interface implementation generated by TMP

2014-08-11 Thread Baz via Digitalmars-d-learn
Hi, I try to get why the last way of generating an interface implementation fails. I've put assumptions: is it right ? --- module itfgen; import std.stdio; interface itf{ void a_int(int p); void a_uint(uint p); } template genimpl(T){ char[] genimpl(){

Re: Linked list as a bidirectional range? I have some questions...

2014-08-11 Thread Gary Willoughby via Digitalmars-d-learn
On Monday, 11 August 2014 at 18:20:51 UTC, H. S. Teoh via Digitalmars-d-learn wrote: If you make your linked list container the same thing as a range over it, then iterating over the range will empty the container as well, which generally isn't what you want. Yes but only if it's been

Are Delimited strings and HereDoc strings just here to suck ?

2014-08-11 Thread Klaus via Digitalmars-d-learn
I mean when writing a D lexer, you necessarly reach the moment when you think: Oh no! is this feature just here to suck ?

Re: Linked list as a bidirectional range? I have some questions...

2014-08-11 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Aug 11, 2014 at 07:35:04PM +, Gary Willoughby via Digitalmars-d-learn wrote: On Monday, 11 August 2014 at 18:20:51 UTC, H. S. Teoh via Digitalmars-d-learn wrote: If you make your linked list container the same thing as a range over it, then iterating over the range will empty the

Re: Are Delimited strings and HereDoc strings just here to suck ?

2014-08-11 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Aug 11, 2014 at 07:47:44PM +, Klaus via Digitalmars-d-learn wrote: I mean when writing a D lexer, you necessarly reach the moment when you think: Oh no! is this feature just here to suck ? I use heredocs every now and then when I need to embed long strings in my program. It's one

Re: Linked list as a bidirectional range? I have some questions...

2014-08-11 Thread Gary Willoughby via Digitalmars-d-learn
On Monday, 11 August 2014 at 20:02:38 UTC, H. S. Teoh via Digitalmars-d-learn wrote: On Mon, Aug 11, 2014 at 07:35:04PM +, Gary Willoughby via Digitalmars-d-learn wrote: On Monday, 11 August 2014 at 18:20:51 UTC, H. S. Teoh via Digitalmars-d-learn wrote: If you make your linked list

Re: Linked list as a bidirectional range? I have some questions...

2014-08-11 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Aug 11, 2014 at 08:22:11PM +, Gary Willoughby via Digitalmars-d-learn wrote: [...] That..is..awesome! and much more simpler than i thought. I get it now, thanks. Is this pattern repeated in phobos? This is essentially what byKey and byValue of the built-in associative arrays do.

Re: Are Delimited strings and HereDoc strings just here to suck ?

2014-08-11 Thread Philippe Sigaud via Digitalmars-d-learn
On Mon, Aug 11, 2014 at 10:09 PM, H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Mon, Aug 11, 2014 at 07:47:44PM +, Klaus via Digitalmars-d-learn wrote: I mean when writing a D lexer, you necessarly reach the moment when you think: Oh no! is this feature

Re: Are Delimited strings and HereDoc strings just here to suck ?

2014-08-11 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Aug 11, 2014 at 10:50:34PM +0200, Philippe Sigaud via Digitalmars-d-learn wrote: On Mon, Aug 11, 2014 at 10:09 PM, H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Mon, Aug 11, 2014 at 07:47:44PM +, Klaus via Digitalmars-d-learn wrote: I mean

Re: Are Delimited strings and HereDoc strings just here to suck ?

2014-08-11 Thread Klaus via Digitalmars-d-learn
On Monday, 11 August 2014 at 20:10:47 UTC, H. S. Teoh via Digitalmars-d-learn wrote: On Mon, Aug 11, 2014 at 07:47:44PM +, Klaus via Digitalmars-d-learn wrote: I mean when writing a D lexer, you necessarly reach the moment when you think: Oh no! is this feature just here to suck ? I use

Re: Are Delimited strings and HereDoc strings just here to suck ?

2014-08-11 Thread Philippe Sigaud via Digitalmars-d-learn
On Mon, Aug 11, 2014 at 10:58 PM, H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: In Flex, one way you can implement heredocs is to have a separate mode where the lexer is scanning for the ending string. So basically you have a sub-lexer that treats the heredoc as

Re: Separate Printing Mantissa and Exponent of a Floating Point

2014-08-11 Thread Nordlöw
On Monday, 11 August 2014 at 15:37:29 UTC, Dominikus Dittes Scherkl wrote: Should be patrs[1], he? No, parts[1] contains a slice to the e separating the mantissa from the exponent.

Re: Separate Printing Mantissa and Exponent of a Floating Point

2014-08-11 Thread Nordlöw
On Monday, 11 August 2014 at 15:30:30 UTC, Justin Whear wrote: 1. http://dlang.org/phobos/std_bitmanip.html#.FloatRep Great! Thx.

Re: Separate Printing Mantissa and Exponent of a Floating Point

2014-08-11 Thread Nordlöw
On Monday, 11 August 2014 at 15:30:30 UTC, Justin Whear wrote: 1. http://dlang.org/phobos/std_bitmanip.html#.FloatRep I'm lacking a use case. See http://dlang.org/library/std/bitmanip/FloatRep.html Is unsafe *(cast(FloatRep*)float_instance) the only way to use this?

Faster ways to redirect stdout of child process to file

2014-08-11 Thread Thomas Mader via Digitalmars-d-learn
I use auto pipes = pipeProcess( cmd, Redirect.stdout | Redirect.stderr ); to redirect stdout of the newly created subprocess via pipes to a file. The redirect itself happens in a newly created thread (because I need to wait for the subprocess to finish to take the exact elapsed

Re: Are Delimited strings and HereDoc strings just here to suck ?

2014-08-11 Thread Brian Schott via Digitalmars-d-learn
On Monday, 11 August 2014 at 19:47:46 UTC, Klaus wrote: I mean when writing a D lexer, you necessarly reach the moment when you think: Oh no! is this feature just here to suck ? They are and they do.

Re: Are Delimited strings and HereDoc strings just here to suck ?

2014-08-11 Thread Brian Schott via Digitalmars-d-learn
On Monday, 11 August 2014 at 22:20:54 UTC, Brian Schott wrote: On Monday, 11 August 2014 at 19:47:46 UTC, Klaus wrote: I mean when writing a D lexer, you necessarly reach the moment when you think: Oh no! is this feature just here to suck ? They are and they do. Also, use this:

Re: Are Delimited strings and HereDoc strings just here to suck ?

2014-08-11 Thread Klaus via Digitalmars-d-learn
On Monday, 11 August 2014 at 22:24:28 UTC, Brian Schott wrote: On Monday, 11 August 2014 at 22:20:54 UTC, Brian Schott wrote: On Monday, 11 August 2014 at 19:47:46 UTC, Klaus wrote: I mean when writing a D lexer, you necessarly reach the moment when you think: Oh no! is this feature just

Re: Are Delimited strings and HereDoc strings just here to suck ?

2014-08-11 Thread Klaus via Digitalmars-d-learn
On Monday, 11 August 2014 at 22:56:27 UTC, Klaus wrote: On Monday, 11 August 2014 at 22:24:28 UTC, Brian Schott wrote: On Monday, 11 August 2014 at 22:20:54 UTC, Brian Schott wrote: On Monday, 11 August 2014 at 19:47:46 UTC, Klaus wrote: I mean when writing a D lexer, you necessarly reach the

Re: overloads and parents. __traits confusion

2014-08-11 Thread Dicebot via Digitalmars-d-learn
On Monday, 11 August 2014 at 13:00:27 UTC, John Colvin wrote: alias Parent = TypeTuple!(__traits(parent, foo!float))[0]; Say hello to optional parens - you are trying to call foo!float() here and apply result to trait.