Re: How to serialize a double.

2016-11-30 Thread Bauss via Digitalmars-d-learn
On Thursday, 1 December 2016 at 00:36:30 UTC, Jake Pittis wrote: How do I convert a double to a ubyte[]? I've tried all sorts of things including converting the double to a ulong and trying to serialize the ulong. For example test bellow fails. unittest { double d = 3.14; ulong

Re: Where should I dump workarounds?

2016-11-30 Thread Dukc via Digitalmars-d-learn
On Wednesday, 30 November 2016 at 21:48:20 UTC, Johan Engelen wrote: Tip: forget about the `master` branch in your own fork on GH. I never use it. Instead, my advice is to locally checkout the master branch from the repo you want to contribute to (dlang/phobos in your case). That works and is

Where should I dump workarounds?

2016-11-30 Thread Dukc via Digitalmars-d-learn
It is my code what caused it after all. How, I do not know yet. But a similar unittest compiled and passed when I tested with the master. Anyway, it seems I have no need to make other branches this time. Thanks for the advice trough. After all, I may need to rebase anyway when doing the pull re

Re: how to catch D Throwables (or exceptions) from C++?

2016-11-30 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 1 December 2016 at 01:58:13 UTC, Timothee Cour wrote: eg: ``` dlib.d: extern(C) void dfun(){assert(0, "some_msg");} clib.cpp: extern "C" void dfun(); void fun(){ try{ dfun(); } catch(...){ // works but how do i get "some_msg" thrown from D? } } ``` portably not su

Re: Use class template as a type

2016-11-30 Thread dm via Digitalmars-d-learn
On Tuesday, 29 November 2016 at 15:56:23 UTC, Jerry wrote: To avoid having to use the Object class directly you can make an base class of the class template. Like: ``` abstract class MyClass {} abstract class MyClassImpl(T) { public: @property const(T) value(){return _value;} @property

how to catch D Throwables (or exceptions) from C++?

2016-11-30 Thread Timothee Cour via Digitalmars-d-learn
eg: ``` dlib.d: extern(C) void dfun(){assert(0, "some_msg");} clib.cpp: extern "C" void dfun(); void fun(){ try{ dfun(); } catch(...){ // works but how do i get "some_msg" thrown from D? } } ```

Re: How to serialize a double.

2016-11-30 Thread Basile B. via Digitalmars-d-learn
On Thursday, 1 December 2016 at 00:36:30 UTC, Jake Pittis wrote: How do I convert a double to a ubyte[]? I've tried all sorts of things including converting the double to a ulong and trying to serialize the ulong. For example test bellow fails. unittest { double d = 3.14; ulong

Re: How to serialize a double.

2016-11-30 Thread H. S. Teoh via Digitalmars-d-learn
On Thu, Dec 01, 2016 at 12:36:30AM +, Jake Pittis via Digitalmars-d-learn wrote: > How do I convert a double to a ubyte[]? > > I've tried all sorts of things including converting the double to a > ulong and trying to serialize the ulong. For example test bellow > fails. > > > unittest {

Re: How to serialize a double.

2016-11-30 Thread Jerry via Digitalmars-d-learn
On Thursday, 1 December 2016 at 00:36:30 UTC, Jake Pittis wrote: How do I convert a double to a ubyte[]? I've tried all sorts of things including converting the double to a ulong and trying to serialize the ulong. For example test bellow fails. unittest { double d = 3.14; ulong

How to serialize a double.

2016-11-30 Thread Jake Pittis via Digitalmars-d-learn
How do I convert a double to a ubyte[]? I've tried all sorts of things including converting the double to a ulong and trying to serialize the ulong. For example test bellow fails. unittest { double d = 3.14; ulong l = *cast(ulong*)(&d); double after = *cast(double*)(&l));

Re: Where should I dump workarounds?

2016-11-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, November 30, 2016 21:48:20 Johan Engelen via Digitalmars-d- learn wrote: > Tip: use both a GUI and the commandline. Without SourceTree [1], > I would be nowhere near as effective with git. > > With rebasing, you'll end up having to force push. Force pushing > is scary (because the rep

Re: Where should I dump workarounds?

2016-11-30 Thread Johan Engelen via Digitalmars-d-learn
On Wednesday, 30 November 2016 at 18:50:42 UTC, Dukc wrote: On Wednesday, 30 November 2016 at 18:26:32 UTC, Jonathan M Davis wrote: [snip] - Jonathan M Davis Luckily, I have made a branch for my stuff instead of using master. But thanks for the help, now I know that it does not matter where

Re: Use class template as a type

2016-11-30 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 30 November 2016 at 14:53:21 UTC, ag0aep6g wrote: On 11/30/2016 10:42 AM, Bauss wrote: Usually casts to base classes can be determined if they're valid at compile-time. Yeah, that's what I said. A cast to a base class is an "upcast". Upcasts don't need run-time checks. The othe

Re: Where should I dump workarounds?

2016-11-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, November 30, 2016 18:50:42 Dukc via Digitalmars-d-learn wrote: > On Wednesday, 30 November 2016 at 18:26:32 UTC, Jonathan M Davis > > wrote: > > [snip] > > > > - Jonathan M Davis > > Luckily, I have made a branch for my stuff instead of using > master. But thanks for the help, now I k

Re: Where should I dump workarounds?

2016-11-30 Thread Dukc via Digitalmars-d-learn
On Wednesday, 30 November 2016 at 18:26:32 UTC, Jonathan M Davis wrote: [snip] - Jonathan M Davis Luckily, I have made a branch for my stuff instead of using master. But thanks for the help, now I know that it does not matter where I create the other branch for that workaround because I can

Re: Where should I dump workarounds?

2016-11-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, November 30, 2016 17:14:37 Dukc via Digitalmars-d-learn wrote: > Well, I was working on std.range.chain (I'm new to contributing), > and when trying to test locally: > > ...\phobos\std\range>rdmd -unittest -main package > C:\D\dmd2\windows\bin\..\..\src\phobos\std\path.d(1319): Error:

Where should I dump workarounds?

2016-11-30 Thread Dukc via Digitalmars-d-learn
Well, I was working on std.range.chain (I'm new to contributing), and when trying to test locally: ...\phobos\std\range>rdmd -unittest -main package C:\D\dmd2\windows\bin\..\..\src\phobos\std\path.d(1319): Error: pure function 'std.path.buildPath!char.buildPath' cannot call impure function 'st

Re: Use class template as a type

2016-11-30 Thread ag0aep6g via Digitalmars-d-learn
On 11/30/2016 10:42 AM, Bauss wrote: Usually casts to base classes can be determined if they're valid at compile-time. Yeah, that's what I said. A cast to a base class is an "upcast". Upcasts don't need run-time checks. The other direction (cast to more derived class) is a downcast. Downcasts

Re: Cannot implicitly convert expression (&sbuf) of type char [1024] to IOREQ *

2016-11-30 Thread Anders S via Digitalmars-d-learn
On Wednesday, 30 November 2016 at 13:47:06 UTC, Anders S wrote: On Wednesday, 30 November 2016 at 12:41:24 UTC, Stefan Koch wrote: On Wednesday, 30 November 2016 at 10:20:35 UTC, Anders S wrote: int [1] argv; /* list of arguments */ Is that supposed to be a VLAIS ? Th

Re: Cannot implicitly convert expression (&sbuf) of type char [1024] to IOREQ *

2016-11-30 Thread Anders S via Digitalmars-d-learn
On Wednesday, 30 November 2016 at 12:41:24 UTC, Stefan Koch wrote: On Wednesday, 30 November 2016 at 10:20:35 UTC, Anders S wrote: int [1] argv; /* list of arguments */ Is that supposed to be a VLAIS ? That will not port to D. It would be helpful If you could share th

Re: Cannot implicitly convert expression (&sbuf) of type char [1024] to IOREQ *

2016-11-30 Thread Stefan Koch via Digitalmars-d-learn
On Wednesday, 30 November 2016 at 10:20:35 UTC, Anders S wrote: int [1] argv; /* list of arguments */ Is that supposed to be a VLAIS ? That will not port to D. It would be helpful If you could share the code and state the intent.

Re: Cannot implicitly convert expression (&sbuf) of type char [1024] to IOREQ *

2016-11-30 Thread Anders S via Digitalmars-d-learn
On Wednesday, 30 November 2016 at 07:16:38 UTC, Anders S wrote: On Tuesday, 29 November 2016 at 23:33:19 UTC, Ali Çehreli wrote: On 11/29/2016 07:30 AM, Anders S wrote: Ali Thanks you all guys, and the cast (IOREQ *) ... did the trick!! I'll have a look at your other comments aswell on

Re: Use class template as a type

2016-11-30 Thread Bauss via Digitalmars-d-learn
On Tuesday, 29 November 2016 at 15:56:23 UTC, Jerry wrote: On Monday, 28 November 2016 at 11:26:41 UTC, dm wrote: ``` abstract class MyClass(T) { public: @property const(T) value(){return _value;} @property void value(T val){_value = val;} ... private: T _value; ... } To avoid hav

Re: Use class template as a type

2016-11-30 Thread Bauss via Digitalmars-d-learn
On Tuesday, 29 November 2016 at 09:58:16 UTC, ag0aep6g wrote: On 11/29/2016 02:21 AM, Basile B. wrote: The cast from a class type to a sub class in itself does absolutely nothing. That can't be right. A bad downcast gives you null, so it has to check the dynamic type information. Compare wit

Re: How can I concatenate a string, a char array and an int

2016-11-30 Thread Andrea Fontana via Digitalmars-d-learn
On Tuesday, 29 November 2016 at 15:01:37 UTC, Anders S wrote: Thanks guys for a really quick answer !! OK, a little bit awkward to use but getting there posting a new question about char * to struct ;) Thanks /anders Also: import std.conv : text; string temp = "This is a number"; string greet