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); c.at(0)

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 Duff's

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 get

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 acc

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 the

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 even

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 written

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: 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 gene

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) w

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 const

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 I

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 the

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 kno

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, hel

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 ) Sc

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 usua