Re: Alternatives to pointers?

2017-09-29 Thread bitwise via Digitalmars-d
On Friday, 29 September 2017 at 01:51:36 UTC, Jerry wrote: [...] Maybe this? ref auto at(T : U[], U)(T arr, size_t index) { return arr[index]; } int main(string[] argv) { int* a = new int(1); int[] b = [1]; int[1] c = [1]; a.at(0); // won't compile b.at(0);

AliasSeq of T.tupleof for class and all base classes

2017-09-29 Thread bitwise via Digitalmars-d-learn
As far as I can tell, this code should compile: class B { int a; } class D1 : B { int b; } class D2 : D1 { int c; } template TupleOf(Classes...) { static if(Classes.length > 1) alias TupleOf = AliasSeq!(Classes[0].tupleof, TupleOf!(Classes[1..$])); else static

Re: problem with opIndex

2017-09-29 Thread Ilya Yaroshenko via Digitalmars-d-learn
On Friday, 29 September 2017 at 19:31:14 UTC, Joseph wrote: I am trying to have a multi-dimensional array and opIndex has to have both an arbitrary number of parameters and allow for slicing. You may want to look into ndslice package source code [1] --Ilya [1]

Re: D's SwitchStatement accepts statements with ridiculous semantics

2017-09-29 Thread sarn via Digitalmars-d
On Friday, 29 September 2017 at 09:56:17 UTC, Dukc wrote: On Friday, 29 September 2017 at 09:12:54 UTC, Don Clugston wrote: Guess what this prints My guess is it prints "1". By "guess" I mean it, I did not test! Anyway reminds me a lot of very badly used gotos. Yeah, it's a lot like

Re: Should we add `a * b` for vectors?

2017-09-29 Thread Manu via Digitalmars-d
On 28 September 2017 at 11:58, Walter Bright via Digitalmars-d < digitalmars-d@puremagic.com> wrote: > On 9/27/2017 4:21 PM, Manu wrote: > >> D does not have ADL, >> > > Thank gawd! :-) > > which will almost certainly lead to _very_ nasty surprises in behaviour. >> > > ADL was always a hack to

Re: Alternatives to pointers?

2017-09-29 Thread Jerry via Digitalmars-d
On Friday, 29 September 2017 at 03:37:53 UTC, Jonathan M Davis wrote: On Friday, September 29, 2017 01:51:36 Jerry via Digitalmars-d wrote: I miss ref variables, for the simple fact that using the square brackets with a ref variable doesn't access the pointer. Don't know how many times I've

Re: Creating a dynamic library

2017-09-29 Thread Tony via Digitalmars-d-learn
On Saturday, 30 September 2017 at 01:02:08 UTC, Elronnd wrote: dmd bla.d bla2.d -shared -fPIC -oflibbla.so Thanks. I don't normally compile right into a .so, but I think this is OK: dmd my_file.o my_other_file.o -shared -of=libutest.so One thing I picked up from SCons is creating

Re: Creating a dynamic library

2017-09-29 Thread Elronnd via Digitalmars-d-learn
dmd bla.d bla2.d -shared -fPIC -oflibbla.so

Creating a dynamic library

2017-09-29 Thread Tony via Digitalmars-d-learn
I would like to know that command line (I am on Linux) I would use to compile a D file and create an object file that is suitable for a Linux dynamic library (.so). I believe it is probably dmd -c -fPIC my_file.d Also, what is the command line to create a dynamic library from one or more

Re: Is it possible to specify the address returned by the address of operator?

2017-09-29 Thread Mengu via Digitalmars-d-learn
On Friday, 29 September 2017 at 02:34:08 UTC, DreadKyller wrote: On Thursday, 28 September 2017 at 14:01:33 UTC, user1234 wrote: [...] I understand that, but because the operator isn't defined normally for classes unless overloaded, then your statement about this being an inconsistency on

Region-based memory management and GC?

2017-09-29 Thread Jon Degenhardt via Digitalmars-d-learn
Have there been any investigations into using region-based memory management (aka memory arenas) in D, possibly in conjunction with GC allocated memory? This would be a very speculative idea, but it'd be interesting to know if there have been looks at this area. My own interest is

[Issue 16995] __traits(getUnittests) doesn't work with separate compilation

2017-09-29 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16995 Walter Bright changed: What|Removed |Added Hardware|x86_64 |All

[Issue 16995] __traits(getUnittests) doesn't work with separate compilation

2017-09-29 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16995 Walter Bright changed: What|Removed |Added CC|

[Issue 17085] Documentation for all traits under SomethingTypeOf missing

2017-09-29 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17085 b2.t...@gmx.com changed: What|Removed |Added Status|NEW |RESOLVED CC|

Re: Is prime missing in photos?

2017-09-29 Thread Elronnd via Digitalmars-d-learn
Well the purpose of the exercise kind of *is* to write a prime number generator. You can look up prime number sieves and algorithms. For REALLY large numbers, that takes an insane amount of time, and you can instead use algorithms such as the ones outlined at

Is prime missing in photos?

2017-09-29 Thread Andre Pany via Digitalmars-d-learn
Hi, Does Phobos have an isPrime function? I cannot find it in the library. I currently have a look at projecteuler.net problem no 7. Such a function makes it a lot easier to solve the problem. https://projecteuler.net/problem=7 Kind regards Andre

Re: Silicon Valley D Meetup - September 28, 2017 - "Open Methods: From C++ to D" by Jean-Louis Leroy

2017-09-29 Thread Ali Çehreli via Digitalmars-d-announce
The slides: https://jll63.github.io/openmethods.d/dlang-meetup-2017-09-28/ Unfortunately, there is no video. Ali On 09/18/2017 10:38 PM, Ali Çehreli wrote: We're excited to be in San Francisco this month:   https://www.meetup.com/D-Lang-Silicon-Valley/events/243022411/ Our host is

Re: dub cross compilation binary extension

2017-09-29 Thread Andre Pany via Digitalmars-d-learn
On Wednesday, 27 September 2017 at 04:08:39 UTC, Joakim wrote: On Tuesday, 26 September 2017 at 17:48:06 UTC, Andre Pany wrote: Hi, I had set up a cross compilation from Windows to Raspberry Pi using LDC and GCC toolchain. Almost everything is working fine. Dub creates a binary which is

[Issue 17829] core.stdc.errno does not work with -betterC

2017-09-29 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17829 --- Comment #2 from github-bugzi...@puremagic.com --- Commits pushed to master at https://github.com/dlang/druntime https://github.com/dlang/druntime/commit/04795c6488943e506150a1da2331cfbcfabb19b1 fix Issue 17829 - core.stdc.errno does not work

Re: problem with opIndex

2017-09-29 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Sep 29, 2017 at 07:31:14PM +, Joseph via Digitalmars-d-learn wrote: > I am trying to have a multi-dimensional array and opIndex has to have > both an arbitrary number of parameters and allow for slicing. > > The problem is if I create opIndex for non-slicing, it looks like > > ref

Re: Allocating byte aligned array

2017-09-29 Thread Igor via Digitalmars-d-learn
On Wednesday, 27 September 2017 at 21:48:35 UTC, timvol wrote: On Wednesday, 27 September 2017 at 21:44:48 UTC, Ali Çehreli wrote: On 09/27/2017 02:39 PM, timvol wrote: [...] void main() { auto mem = new ubyte[1024+15]; auto ptr = cast(ubyte*)(cast(ulong)(mem.ptr + 15) & ~0x0FUL);

Re: D's SwitchStatement accepts statements with ridiculous semantics

2017-09-29 Thread Timon Gehr via Digitalmars-d
On 29.09.2017 17:05, Don Clugston wrote: I don't see what your proposed grammar change accomplishes: switch(i){     for(i=8;i<10;++i){     case 7:     writeln(i);     return;     default:{}     } } I.e., you seem to have misidentified the culprit. Whether or not to

problem with opIndex

2017-09-29 Thread Joseph via Digitalmars-d-learn
I am trying to have a multi-dimensional array and opIndex has to have both an arbitrary number of parameters and allow for slicing. The problem is if I create opIndex for non-slicing, it looks like ref auto opIndex(T...)(T index) and this one catches all templates. But slices do not return

Re: Detect if variable defined

2017-09-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/29/17 2:03 PM, Joseph wrote: static if () {  enum x; } static if (isDefined!x) { } What's the correct way to check if a variable has been defined? (note x may or may not be defined above. I need to know if it is) Check to see that it has a type: static if(is(typeof(x))) { } -Steve

Re: opDollar any

2017-09-29 Thread Ali Çehreli via Digitalmars-d-learn
On 09/29/2017 11:34 AM, Joseph wrote: Trying to do multi-dimension array but op-dollar doesn't seem to support arbitrary dimensions @property int opDollar(size_t dim : k)() { return dims[k]; } It's called by multi-dimensional opIndex (or opSlice and perhaps others?; can be very

Re: Detect if variable defined

2017-09-29 Thread arturg via Digitalmars-d-learn
On Friday, 29 September 2017 at 18:03:52 UTC, Joseph wrote: static if () { enum x; } static if (isDefined!x) { } What's the correct way to check if a variable has been defined? (note x may or may not be defined above. I need to know if it is) import std.traits; static if(hasMember!(T,

opDollar any

2017-09-29 Thread Joseph via Digitalmars-d-learn
Trying to do multi-dimension array but op-dollar doesn't seem to support arbitrary dimensions @property int opDollar(size_t dim : k)() { return dims[k]; }

Detect if variable defined

2017-09-29 Thread Joseph via Digitalmars-d-learn
static if () { enum x; } static if (isDefined!x) { } What's the correct way to check if a variable has been defined? (note x may or may not be defined above. I need to know if it is)

Re: I need runtime reflection

2017-09-29 Thread bitwise via Digitalmars-d
On Friday, 29 September 2017 at 16:40:38 UTC, Gheorghe Gabriel wrote: On Friday, 29 September 2017 at 16:24:32 UTC, bitwise wrote: On Friday, 29 September 2017 at 11:05:00 UTC, Gheorghe Gabriel wrote: [...] If i compile this script to a .dll DLL support for D is currently very spotty. Before

Re: I need runtime reflection

2017-09-29 Thread Gheorghe Gabriel via Digitalmars-d
On Friday, 29 September 2017 at 16:24:32 UTC, bitwise wrote: On Friday, 29 September 2017 at 11:05:00 UTC, Gheorghe Gabriel wrote: [...] If i compile this script to a .dll DLL support for D is currently very spotty. Before investing too much time, I would suggest confirming that DLLs are

Re: D's SwitchStatement accepts statements with ridiculous semantics

2017-09-29 Thread H. S. Teoh via Digitalmars-d
On Fri, Sep 29, 2017 at 12:32:02PM +0200, Timon Gehr via Digitalmars-d wrote: [...] > It is very likely that this part of the grammar was deliberately > copied from C. It's also consistent with how all other control flow > constructs are parsed. I believe one of the reasons the grammar was

Re: I need runtime reflection

2017-09-29 Thread bitwise via Digitalmars-d
On Friday, 29 September 2017 at 11:05:00 UTC, Gheorghe Gabriel wrote: [...] If i compile this script to a .dll DLL support for D is currently very spotty. Before investing too much time, I would suggest confirming that DLLs are even properly supported for your target platform at all.

Re: D's SwitchStatement accepts statements with ridiculous semantics

2017-09-29 Thread Don Clugston via Digitalmars-d
On Friday, 29 September 2017 at 10:32:02 UTC, Timon Gehr wrote: On 29.09.2017 11:12, Don Clugston wrote: Guess what this prints import std.stdio; void main() {   int i = 0;   switch (i) for (i = 8; i < 10; ++i)   {     case 7:     writeln(i);     return;     default: ;  

Re: Day of week from date

2017-09-29 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, September 29, 2017 14:34:04 aberba via Digitalmars-d-learn wrote: > On Friday, 29 September 2017 at 03:42:18 UTC, Jonathan M Davis > > wrote: > > On Friday, September 29, 2017 04:32:44 rikki cattermole via > > > > Digitalmars-d- learn wrote: > >> On 29/09/2017 4:25 AM, Joel wrote: > >>

Re: Day of week from date

2017-09-29 Thread aberba via Digitalmars-d-learn
On Friday, 29 September 2017 at 03:42:18 UTC, Jonathan M Davis wrote: On Friday, September 29, 2017 04:32:44 rikki cattermole via Digitalmars-d- learn wrote: On 29/09/2017 4:25 AM, Joel wrote: > With a given date, I want to know what day it is (like > Sunday, Monday, > etc). > > I had a look

Re: DlangIDE v0.8.0 released

2017-09-29 Thread bitwise via Digitalmars-d-announce
On Thursday, 28 September 2017 at 11:25:35 UTC, Vadim Lopatin wrote: [...] Fixed. Awesome, looks perfect now. Thanks!

Re: DlangIDE v0.8.0 released

2017-09-29 Thread aberba via Digitalmars-d-announce
On Friday, 29 September 2017 at 07:18:42 UTC, Martin Tschierschke wrote: On Wednesday, 27 September 2017 at 12:34:33 UTC, Dmitry wrote: On Wednesday, 27 September 2017 at 08:00:21 UTC, Traktor Toni wrote: [...] The IDE should contain the compiler for convenience No. I think that including

Re: Unsigned comparison operators

2017-09-29 Thread Stefan Koch via Digitalmars-d
On Friday, 29 September 2017 at 11:20:13 UTC, Cecil Ward wrote: I love the D >>> operator and I use it a lot. So much safer than the chaos in C. I would absolutely love to have unsigned comparison operators in D. Do you agree? What on earth would the syntax be like? Yes, I could write a

Re: ACLs for variables - lock / unlock idea

2017-09-29 Thread Cecil Ward via Digitalmars-d
On Friday, 29 September 2017 at 13:07:32 UTC, Atila Neves wrote: auto modifiable = foo(); { const nonModifiable = modifiable; //... } I had already thought about using two names. I don’t think that using a kind of ‘const-alias’ mechanism (or ‘const reference’, in the C++ var& sense)

Re: ACLs for variables - lock / unlock idea

2017-09-29 Thread Atila Neves via Digitalmars-d
On Friday, 29 September 2017 at 11:12:32 UTC, Cecil Ward wrote: An idea, I’d be interested to hear if this might be at all useful to anyone - If and only if a variable is declared as modifiable (neither immutable nor const), would it possibly be useful to be able to have a kind of scope

Unsigned comparison operators

2017-09-29 Thread Cecil Ward via Digitalmars-d
I love the D >>> operator and I use it a lot. So much safer than the chaos in C. I would absolutely love to have unsigned comparison operators in D. Do you agree? What on earth would the syntax be like? Yes, I could write a generic function or something, but the result would look ugly. And

ACLs for variables - lock / unlock idea

2017-09-29 Thread Cecil Ward via Digitalmars-d
An idea, I’d be interested to hear if this might be at all useful to anyone - If and only if a variable is declared as modifiable (neither immutable nor const), would it possibly be useful to be able to have a kind of scope const on/off switch to either impose const within a block, and/or

Re: I need runtime reflection

2017-09-29 Thread Gheorghe Gabriel via Digitalmars-d
On Friday, 29 September 2017 at 09:34:26 UTC, JN wrote: On Wednesday, 27 September 2017 at 20:03:27 UTC, Gheorghe Gabriel wrote: Hi, I have a 3D scene editor. I need my scripts to be dynamically loaded in the scene. In c# or java I can use reflections to do that. How can I do that with D? I

Re: D's SwitchStatement accepts statements with ridiculous semantics

2017-09-29 Thread Timon Gehr via Digitalmars-d
On 29.09.2017 11:12, Don Clugston wrote: Guess what this prints import std.stdio; void main() {   int i = 0;   switch (i) for (i = 8; i < 10; ++i)   {     case 7:     writeln(i);     return;     default: ;   } } Why does this even compile? It's because the grammar

Re: D's SwitchStatement accepts statements with ridiculous semantics

2017-09-29 Thread Dukc via Digitalmars-d
On Friday, 29 September 2017 at 09:12:54 UTC, Don Clugston wrote: Guess what this prints My guess is it prints "1". By "guess" I mean it, I did not test! Anyway reminds me a lot of very badly used gotos.

Re: I need runtime reflection

2017-09-29 Thread JN via Digitalmars-d
On Wednesday, 27 September 2017 at 20:03:27 UTC, Gheorghe Gabriel wrote: Hi, I have a 3D scene editor. I need my scripts to be dynamically loaded in the scene. In c# or java I can use reflections to do that. How can I do that with D? I know that std.traits only works in compile time. Please,

D's SwitchStatement accepts statements with ridiculous semantics

2017-09-29 Thread Don Clugston via Digitalmars-d
Guess what this prints import std.stdio; void main() { int i = 0; switch (i) for (i = 8; i < 10; ++i) { case 7: writeln(i); return; default: ; } } Why does this even compile? It's because the grammar is: SwitchStatement: switch ( Expression )

Re: Alternatives to pointers?

2017-09-29 Thread Dukc via Digitalmars-d
On Friday, 29 September 2017 at 01:51:36 UTC, Jerry wrote: Don't know how many times I've accidentially used a pointer as an array. Using @safe let's the compiler to catch that. Well, in it you can't use pointer arithmetic even explicitly, but if you have many elements to point at you're

[Issue 15531] dmd.conf linker flags should be prepended instead of appended to subsequent linker flags

2017-09-29 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15531 Heromyth changed: What|Removed |Added CC||bitwo...@qq.com --- Comment #2

Re: DlangIDE v0.8.0 released

2017-09-29 Thread Martin Tschierschke via Digitalmars-d-announce
On Wednesday, 27 September 2017 at 12:34:33 UTC, Dmitry wrote: On Wednesday, 27 September 2017 at 08:00:21 UTC, Traktor Toni wrote: [...] The IDE should contain the compiler for convenience No. I think that including DMD & Co. into DlangIde is not the right approach, but offering one D-NOW

Re: Using dates to get days count

2017-09-29 Thread Joel via Digitalmars-d-learn
On Friday, 29 September 2017 at 06:32:19 UTC, rikki cattermole wrote: On 29/09/2017 7:29 AM, Joel wrote: How do I count the days between to dates? https://dlang.org/phobos/std_datetime_date.html#.Date.opBinary.2 https://dlang.org/phobos/core_time.html#.Duration.total Thanks rikki. I did

Re: Using dates to get days count

2017-09-29 Thread rikki cattermole via Digitalmars-d-learn
On 29/09/2017 7:29 AM, Joel wrote: How do I count the days between to dates? https://dlang.org/phobos/std_datetime_date.html#.Date.opBinary.2 https://dlang.org/phobos/core_time.html#.Duration.total

Using dates to get days count

2017-09-29 Thread Joel via Digitalmars-d-learn
How do I count the days between to dates?