Re: import in mixin template

2016-05-26 Thread vitus via Digitalmars-d-learn
On Thursday, 26 May 2016 at 05:47:36 UTC, Era Scarecrow wrote: On Thursday, 26 May 2016 at 05:20:25 UTC, vitus wrote: Why 'alias wln1 = writeln;' doesnt't work but 'alias wln2 = std.stdio.writeln;' work when import is not static? Why 'wln2("test");' work but 'std.stdio.writeln("test");' doesn't

Testing array ptr for offset 0...

2016-05-26 Thread Era Scarecrow via Digitalmars-d-learn
So I'm experimenting and want to override how arrays are managed for a short duration, this is for optimization of not having to make another array to keep track of lengths and then shorten them when i can in fact just manage it myself *very* briefly. So, I need to make sure the structure is

Re: What's wrong with my usage of std.algorithm.map in this code example?

2016-05-26 Thread Chris via Digitalmars-d-learn
On Wednesday, 25 May 2016 at 19:07:32 UTC, Era Scarecrow wrote: On Wednesday, 25 May 2016 at 13:27:28 UTC, Chris wrote: Why can the tuple be iterated with foreach, as in my quick fix, and indexed with tuple[0..], but is not accepted as a range? What are the differences? Is there a way to rangif

Re: Testing array ptr for offset 0...

2016-05-26 Thread Kagamin via Digitalmars-d-learn
try this: struct X { byte[] data; alias data this; }

Re: Testing array ptr for offset 0...

2016-05-26 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 26 May 2016 at 09:16:48 UTC, Kagamin wrote: try this: struct X { byte[] data; alias data this; } This doesn't help me with what I want, and effectively does nothing as far as I can tell. Although testing is showing managing the pointer & length directly is a lit

Re: full copies on assignment

2016-05-26 Thread John Nixon via Digitalmars-d-learn
On Wednesday, 25 May 2016 at 15:44:34 UTC, Marc Schütz wrote: On Tuesday, 24 May 2016 at 20:58:11 UTC, John Nixon wrote: On Tuesday, 24 May 2016 at 15:17:37 UTC, Adam D. Ruppe wrote: On Tuesday, 24 May 2016 at 14:29:53 UTC, John Nixon wrote: Or add an explicit constructor: struct CS {

Re: Testing array ptr for offset 0...

2016-05-26 Thread ag0aep6g via Digitalmars-d-learn
On 05/26/2016 09:51 AM, Era Scarecrow wrote: So I'm experimenting and want to override how arrays are managed for a short duration, this is for optimization of not having to make another array to keep track of lengths and then shorten them when i can in fact just manage it myself *very* briefly

Re: Testing array ptr for offset 0...

2016-05-26 Thread Alex Parrill via Digitalmars-d-learn
On Thursday, 26 May 2016 at 07:51:46 UTC, Era Scarecrow wrote: ... This smells like an XY problem [0]. Why exactly do you need the internal layout of the array structure? The line "not having to make another array to keep track of lengths and then shorten them" is fairly vague. "Shortening"

Re: Testing array ptr for offset 0...

2016-05-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 26 May 2016 at 07:51:46 UTC, Era Scarecrow wrote: If the ptr is at offset 0, we declare it first, otherwise second, simple... Except this fails since "no property 'offsetof' for type 'void*'". SO... I make a template to test for it instead. Built-in arrays are kinda magical and

Re: Testing array ptr for offset 0...

2016-05-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 26 May 2016 at 12:30:30 UTC, Alex Parrill wrote: The line "not having to make another array to keep track of lengths and then shorten them" is fairly vague. "Shortening" an array via slicing is basically free (it's just some integer arithmetic), but I'm not sure if that's what you

Why do some T.init evaluate to true while others to false?

2016-05-26 Thread ArturG via Digitalmars-d-learn
for example: if(any floatingpoint.init) will be true if(any char.init) also true if("") also true while others are false e.g. string s; if(s) will be false all others are also false or did i miss any?

Effect of declaring a class immutable ?

2016-05-26 Thread chmike via Digitalmars-d-learn
I couldn't find any information about this on the dlang web site. What is the effect adding the immutable attribute to a class like this immutable class MyClass { ... } The compiler doesn't complain. Will it add the immutable attribute to all members ?

Runtime.loadLibrary linker errors

2016-05-26 Thread Carl Vogel via Digitalmars-d-learn
Hi, Whenever I try to compile code that relies on Runtime.loadLibrary, I get a linker error during compilation. ``` Undefined symbols for architecture x86_64: "_rt_loadLibrary", referenced from: _D4core7runtime7Runtime17__T11loadLibraryZ11loadLibraryFxAaZPv in ll_test.o ld: symbol(s

Re: Effect of declaring a class immutable ?

2016-05-26 Thread ArturG via Digitalmars-d-learn
On Thursday, 26 May 2016 at 14:12:23 UTC, chmike wrote: I couldn't find any information about this on the dlang web site. What is the effect adding the immutable attribute to a class like this immutable class MyClass { ... } The compiler doesn't complain. Will it add the immutable attribute

Re: Effect of declaring a class immutable ?

2016-05-26 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, May 26, 2016 14:12:23 chmike via Digitalmars-d-learn wrote: > I couldn't find any information about this on the dlang web site. > > What is the effect adding the immutable attribute to a class like > this > > immutable class MyClass { ... } > > The compiler doesn't complain. > Will it

Re: Effect of declaring a class immutable ?

2016-05-26 Thread Basile B. via Digitalmars-d-learn
On Thursday, 26 May 2016 at 14:12:23 UTC, chmike wrote: I couldn't find any information about this on the dlang web site. What is the effect adding the immutable attribute to a class like this immutable class MyClass { ... } The compiler doesn't complain. Will it add the immutable attribute

Re: Why do some T.init evaluate to true while others to false?

2016-05-26 Thread Basile B. via Digitalmars-d-learn
On Thursday, 26 May 2016 at 14:03:16 UTC, ArturG wrote: for example: if(any floatingpoint.init) will be true if(any char.init) also true if("") also true while others are false e.g. string s; if(s) will be false all others are also false or did i miss any? It's a shortcut that works for cert

Re: Why do some T.init evaluate to true while others to false?

2016-05-26 Thread Basile B. via Digitalmars-d-learn
On Thursday, 26 May 2016 at 15:11:50 UTC, Basile B. wrote: On Thursday, 26 May 2016 at 14:03:16 UTC, ArturG wrote: [...] [...] - integral(*): if (i) <=> if (i > 0) I obviously meant: - integral(*): if (i) <=> if (i <> 0) and "<=>" stands for "equivalence"

Re: Why do some T.init evaluate to true while others to false?

2016-05-26 Thread Basile B. via Digitalmars-d-learn
On Thursday, 26 May 2016 at 15:14:21 UTC, Basile B. wrote: On Thursday, 26 May 2016 at 15:11:50 UTC, Basile B. wrote: On Thursday, 26 May 2016 at 14:03:16 UTC, ArturG wrote: [...] [...] - integral(*): if (i) <=> if (i > 0) I obviously meant: - integral(*): if (i) <=> if (i <> 0) and "<=>

Re: Why do some T.init evaluate to true while others to false?

2016-05-26 Thread arturg via Digitalmars-d-learn
On Thursday, 26 May 2016 at 15:15:57 UTC, Basile B. wrote: On Thursday, 26 May 2016 at 15:14:21 UTC, Basile B. wrote: On Thursday, 26 May 2016 at 15:11:50 UTC, Basile B. wrote: On Thursday, 26 May 2016 at 14:03:16 UTC, ArturG wrote: [...] [...] - integral(*): if (i) <=> if (i > 0) I obvio

Re: Why do some T.init evaluate to true while others to false?

2016-05-26 Thread ag0aep6g via Digitalmars-d-learn
On 05/26/2016 04:03 PM, ArturG wrote: for example: if(any floatingpoint.init) will be true if(any char.init) also true if("") also true while others are false e.g. string s; if(s) will be false all others are also false or did i miss any? What does it matter?

Re: Why do some T.init evaluate to true while others to false?

2016-05-26 Thread ArturG via Digitalmars-d-learn
On Thursday, 26 May 2016 at 15:25:26 UTC, ag0aep6g wrote: On 05/26/2016 04:03 PM, ArturG wrote: for example: if(any floatingpoint.init) will be true if(any char.init) also true if("") also true while others are false e.g. string s; if(s) will be false all others are also false or did i miss a

Re: Why do some T.init evaluate to true while others to false?

2016-05-26 Thread Basile B. via Digitalmars-d-learn
On Thursday, 26 May 2016 at 15:25:03 UTC, arturg wrote: On Thursday, 26 May 2016 at 15:15:57 UTC, Basile B. wrote: On Thursday, 26 May 2016 at 15:14:21 UTC, Basile B. wrote: On Thursday, 26 May 2016 at 15:11:50 UTC, Basile B. wrote: On Thursday, 26 May 2016 at 14:03:16 UTC, ArturG wrote: [...

Easier way to add libraries to visual d?

2016-05-26 Thread TheDGuy via Digitalmars-d-learn
Hi, i use Visual D as a plugin for visual studio to create D applications. But what bothers me a bit is that i have to tell visual D the exact link to the .lib file for every lib i want to use in the project (!). So these are the steps i have to make to get an external lib working: 1. create

Re: Easier way to add libraries to visual d?

2016-05-26 Thread Basile B. via Digitalmars-d-learn
On Thursday, 26 May 2016 at 15:11:05 UTC, TheDGuy wrote: Hi, i use Visual D as a plugin for visual studio to create D applications. But what bothers me a bit is that i have to tell visual D the exact link to the .lib file for every lib i want to use in the project (!). So these are the steps i

Re: Why do some T.init evaluate to true while others to false?

2016-05-26 Thread ArturG via Digitalmars-d-learn
On Thursday, 26 May 2016 at 15:29:52 UTC, Basile B. wrote: float.init is not equal to 0.0f. In D FP points values are initialized to nan (not a number). By the way for strings it works, it's like the array case I described in the first answer). yes i guess i tested all/most types and know

Re: Why do some T.init evaluate to true while others to false?

2016-05-26 Thread Basile B. via Digitalmars-d-learn
On Thursday, 26 May 2016 at 15:34:50 UTC, ArturG wrote: On Thursday, 26 May 2016 at 15:29:52 UTC, Basile B. wrote: float.init is not equal to 0.0f. In D FP points values are initialized to nan (not a number). By the way for strings it works, it's like the array case I described in the firs

Re: Why do some T.init evaluate to true while others to false?

2016-05-26 Thread ag0aep6g via Digitalmars-d-learn
On 05/26/2016 05:28 PM, ArturG wrote: On Thursday, 26 May 2016 at 15:25:26 UTC, ag0aep6g wrote: [...] What does it matter? You would have to create special cases for them. When? If you want to check if something is the .init value, compare against .init.

Re: Easier way to add libraries to visual d?

2016-05-26 Thread TheDGuy via Digitalmars-d-learn
On Thursday, 26 May 2016 at 15:21:40 UTC, Basile B. wrote: Use Coedit: the widget "library manager" allow to register libraries in a single click and then they are usable on the fly, in the projects or in a runnable modules, without specifying anything (except a (*) in a project setting calle

Re: Why do some T.init evaluate to true while others to false?

2016-05-26 Thread ArturG via Digitalmars-d-learn
On Thursday, 26 May 2016 at 15:38:55 UTC, Basile B. wrote: because nan is not 0 and that the shortcut for float is if (fpValue) <=> if (fpValue != 0) if (!fpValue)<=> if (fpValue == 0) There's no relation between the initializer and the shortcut. It's not because for some values the shortcut

Re: Why do some T.init evaluate to true while others to false?

2016-05-26 Thread Basile B. via Digitalmars-d-learn
On Thursday, 26 May 2016 at 15:34:50 UTC, ArturG wrote: On Thursday, 26 May 2016 at 15:29:52 UTC, Basile B. wrote: float.init is not equal to 0.0f. In D FP points values are initialized to nan (not a number). By the way for strings it works, it's like the array case I described in the firs

Re: Why do some T.init evaluate to true while others to false?

2016-05-26 Thread Basile B. via Digitalmars-d-learn
On Thursday, 26 May 2016 at 15:48:18 UTC, Basile B. wrote: On Thursday, 26 May 2016 at 15:34:50 UTC, ArturG wrote: On Thursday, 26 May 2016 at 15:29:52 UTC, Basile B. wrote: float.init is not equal to 0.0f. In D FP points values are initialized to nan (not a number). By the way for strings

Re: Easier way to add libraries to visual d?

2016-05-26 Thread Basile B. via Digitalmars-d-learn
On Thursday, 26 May 2016 at 15:41:45 UTC, TheDGuy wrote: On Thursday, 26 May 2016 at 15:21:40 UTC, Basile B. wrote: Use Coedit: the widget "library manager" allow to register libraries in a single click and then they are usable on the fly, in the projects or in a runnable modules, without sp

Re: Easier way to add libraries to visual d?

2016-05-26 Thread TheDGuy via Digitalmars-d-learn
On Thursday, 26 May 2016 at 16:01:22 UTC, Basile B. wrote: To register a DUB package, you can either fetch (DUB icon) or clone the repo, open the DUB JSON project, compile the right config, then in the libman there's a icon with a gray chain over a book. Click this icon and the library is regis

Re: Operator overloading through UFCS doesn't work

2016-05-26 Thread Elie Morisse via Digitalmars-d-learn
On Thursday, 26 May 2016 at 06:23:17 UTC, Jonathan M Davis wrote: The difference is that it's impossible to do 10.opBinary!"+"(15), so if you're forced to do foo.opBinary!"+"(bar) to get around a symbol conflict, it won't work with built-in types. Obviously operator overloading should be limi

Re: Why do some T.init evaluate to true while others to false?

2016-05-26 Thread ArturG via Digitalmars-d-learn
On Thursday, 26 May 2016 at 15:51:39 UTC, Basile B. wrote: Oh, I'm so sorry ! I totally missed the point of the Q. float.nan is not a "unique" value. Several values verify "nan" (Look at std.math.isNan). So I suppose it's simpler to test for nullity. Though with the sign there's also two poss

Re: Easier way to add libraries to visual d?

2016-05-26 Thread Basile B. via Digitalmars-d-learn
On Thursday, 26 May 2016 at 16:21:30 UTC, TheDGuy wrote: On Thursday, 26 May 2016 at 16:01:22 UTC, Basile B. wrote: To register a DUB package, you can either fetch (DUB icon) or clone the repo, open the DUB JSON project, compile the right config, then in the libman there's a icon with a gray ch

Re: Easier way to add libraries to visual d?

2016-05-26 Thread Basile B. via Digitalmars-d-learn
On Thursday, 26 May 2016 at 16:53:42 UTC, Basile B. wrote: On Thursday, 26 May 2016 at 16:21:30 UTC, TheDGuy wrote: On Thursday, 26 May 2016 at 16:01:22 UTC, Basile B. wrote: To register a DUB package, you can either fetch (DUB icon) or clone the repo, open the DUB JSON project, compile the rig

Re: Easier way to add libraries to visual d?

2016-05-26 Thread TheDGuy via Digitalmars-d-learn
On Thursday, 26 May 2016 at 17:02:06 UTC, TheDGuy wrote: Thanks, now i found it. If i try to add for example 'colorize' as a package i get: Fetching serial-port ~master... Placing serial-port ~master to C:\Users\luc\AppData\Roaming\dub\packages\... Neither a package description file, nor so

Re: Easier way to add libraries to visual d?

2016-05-26 Thread TheDGuy via Digitalmars-d-learn
On Thursday, 26 May 2016 at 16:53:42 UTC, Basile B. wrote: - Registering a dub package from online is in the "library manager" - The DUB project editor is a widget that's not docked by default, see in the menu "Windows", the item "Dub project editor". The Native project configuration and ed

Re: Easier way to add libraries to visual d?

2016-05-26 Thread Rainer Schuetze via Digitalmars-d-learn
On 26.05.2016 17:11, TheDGuy wrote: Hi, i use Visual D as a plugin for visual studio to create D applications. But what bothers me a bit is that i have to tell visual D the exact link to the .lib file for every lib i want to use in the project (!). So these are the steps i have to make to get a

Re: Easier way to add libraries to visual d?

2016-05-26 Thread Basile B. via Digitalmars-d-learn
On Thursday, 26 May 2016 at 17:02:06 UTC, TheDGuy wrote: On Thursday, 26 May 2016 at 16:53:42 UTC, Basile B. wrote: [...] Thanks, now i found it. If i try to add for example 'colorize' as a package i get: Fetching serial-port ~master... Placing serial-port ~master to C:\Users\luc\AppData\Ro

Re: Easier way to add libraries to visual d?

2016-05-26 Thread TheDGuy via Digitalmars-d-learn
On Thursday, 26 May 2016 at 17:06:03 UTC, Basile B. wrote: colorize works. You meant "serial-port" ? Well, i get the same message for both packages...Even though it creates a new folder with all the files in AppData\Roaming\dub\packages

Re: Easier way to add libraries to visual d?

2016-05-26 Thread Basile B. via Digitalmars-d-learn
On Thursday, 26 May 2016 at 17:06:03 UTC, Basile B. wrote: On Thursday, 26 May 2016 at 17:02:06 UTC, TheDGuy wrote: On Thursday, 26 May 2016 at 16:53:42 UTC, Basile B. wrote: [...] Thanks, now i found it. If i try to add for example 'colorize' as a package i get: Fetching serial-port ~maste

Re: Easier way to add libraries to visual d?

2016-05-26 Thread Basile B. via Digitalmars-d-learn
On Thursday, 26 May 2016 at 17:09:03 UTC, TheDGuy wrote: On Thursday, 26 May 2016 at 17:06:03 UTC, Basile B. wrote: colorize works. You meant "serial-port" ? Well, i get the same message for both packages...Even though it creates a new folder with all the files in AppData\Roaming\dub\package

Re: Easier way to add libraries to visual d?

2016-05-26 Thread Basile B. via Digitalmars-d-learn
On Thursday, 26 May 2016 at 17:09:03 UTC, TheDGuy wrote: On Thursday, 26 May 2016 at 17:06:03 UTC, Basile B. wrote: colorize works. You meant "serial-port" ? Well, i get the same message for both packages...Even though it creates a new folder with all the files in AppData\Roaming\dub\package

Re: Easier way to add libraries to visual d?

2016-05-26 Thread Basile B. via Digitalmars-d-learn
On Thursday, 26 May 2016 at 17:09:03 UTC, TheDGuy wrote: On Thursday, 26 May 2016 at 17:06:03 UTC, Basile B. wrote: colorize works. You meant "serial-port" ? Well, i get the same message for both packages...Even though it creates a new folder with all the files in AppData\Roaming\dub\package

Re: Easier way to add libraries to visual d?

2016-05-26 Thread TheDGuy via Digitalmars-d-learn
On Thursday, 26 May 2016 at 17:25:25 UTC, Basile B. wrote: I'm on Windows now. I'm sorry but both packages were setup successfully. What you can do is the other way: - clone the git repos. - open the DUB json as project. - choose the right config in the inspector. - compile. - while the proje

Re: Operator overloading through UFCS doesn't work

2016-05-26 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, May 26, 2016 16:24:37 Elie Morisse via Digitalmars-d-learn wrote: > On Thursday, 26 May 2016 at 06:23:17 UTC, Jonathan M Davis wrote: > > The difference is that it's impossible to do > > 10.opBinary!"+"(15), so if you're forced to do > > foo.opBinary!"+"(bar) to get around a symbol con

Re: Easier way to add libraries to visual d?

2016-05-26 Thread Basile B. via Digitalmars-d-learn
On Thursday, 26 May 2016 at 19:07:42 UTC, TheDGuy wrote: On Thursday, 26 May 2016 at 17:25:25 UTC, Basile B. wrote: I'm on Windows now. I'm sorry but both packages were setup successfully. What you can do is the other way: - clone the git repos. - open the DUB json as project. - choose the r

Re: Operator overloading through UFCS doesn't work

2016-05-26 Thread Timon Gehr via Digitalmars-d-learn
On 25.05.2016 01:19, Elie Morisse wrote: On Saturday, 13 October 2012 at 22:58:56 UTC, Timon Gehr wrote: Afaik free-function operator overloads (but not in the context of UFCS) were considered and turned down because D did not want to get amidst discussions about adding Koenig lookup. UFCS does

Re: Easier way to add libraries to visual d?

2016-05-26 Thread TheDGuy via Digitalmars-d-learn
On Thursday, 26 May 2016 at 20:25:43 UTC, Basile B. wrote: But the procedure I described is very easy. you just have to clone, compile and click a button in the library manager. It's even better because you can choose which version to compile by "git checkout vx.x.x" while using the "DUB button

Re: Testing array ptr for offset 0...

2016-05-26 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 26 May 2016 at 11:47:13 UTC, ag0aep6g wrote: I don't follow. Why can't you use a built-in array? What can you do with the stand-in that you can't do with the array itself? I can do the job with the built-in arrays, however the need for another temporary array to keep track of le

Re: Testing array ptr for offset 0...

2016-05-26 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 26 May 2016 at 12:33:31 UTC, Adam D. Ruppe wrote: On Thursday, 26 May 2016 at 12:30:30 UTC, Alex Parrill wrote: The line "not having to make another array to keep track of lengths and then shorten them" is fairly vague. "Shortening" an array via slicing is basically free (it's just

Re: Easier way to add libraries to visual d?

2016-05-26 Thread Basile B. via Digitalmars-d-learn
On Thursday, 26 May 2016 at 20:46:31 UTC, TheDGuy wrote: On Thursday, 26 May 2016 at 20:25:43 UTC, Basile B. wrote: [...] I tried this with the gfm-package. I opened the dub.json file as a project and clicked 'Compilation'-> 'Compile Project' then it did its things: [...] gfm doesn't yie

Re: Testing array ptr for offset 0...

2016-05-26 Thread ag0aep6g via Digitalmars-d-learn
On 05/26/2016 11:13 PM, Era Scarecrow wrote: By adding a struct overload for opOpAssign I can shrink it all down to this, and avoid lengths entirely... As such internally the length starts at 0, and checks are in place to ensure the bounds are never exceeded. void scan(ref Data[][] data, C

Re: Testing array ptr for offset 0...

2016-05-26 Thread Era Scarecrow via Digitalmars-d-learn
On Thursday, 26 May 2016 at 22:15:42 UTC, ag0aep6g wrote: On 05/26/2016 11:13 PM, Era Scarecrow wrote: void scan(ref Data[][] data, Condition cond) { foreach(i; ...) { if (cond) data[i] ~= ... } } Sorry, I'm still lost. Why can't you do whatever you're doing in