Re: Alternatives to pointers?

2017-09-28 Thread Elronnd via Digitalmars-d
On Friday, 29 September 2017 at 03:37:53 UTC, Jonathan M Davis 
wrote:
You could always create a wrapper struct for the pointer and 
then not overload opIndex.


...alternatively, you could create a wrapper struct for the 
pointer, do 'alias this' on said pointer, and then overload 
opIndex to call static assert(0);.  Like this:



struct Ptr(T) {
private T *_ptr;
alias _ptr this;

this(T *val) {
_ptr = val;
}

void opIndex(size_t index)() {
static assert(0);
}
}


Re: Alternatives to pointers?

2017-09-28 Thread Jonathan M Davis via Digitalmars-d
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 accidentially used a pointer as an
> array. Not very easy to catch especially if the object has
> pointers to other objects of the same type. Possibly adding
> something like this, if ref variables are off the table?
>
> @noarray int* value;
> value[x] = 10; // compile error, pointer is not an array.

You could always create a wrapper struct for the pointer and then not
overload opIndex.

- Jonathan M Davis



Alternatives to pointers?

2017-09-28 Thread Jerry via Digitalmars-d
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 accidentially used a pointer as an 
array. Not very easy to catch especially if the object has 
pointers to other objects of the same type. Possibly adding 
something like this, if ref variables are off the table?


@noarray int* value;
value[x] = 10; // compile error, pointer is not an array.


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

2017-09-28 Thread Wyatt via Digitalmars-d
On Thursday, 28 September 2017 at 01:58:24 UTC, Walter Bright 
wrote:
ADL was always a hack to get around the wretched overloading 
symbol lookup behavior in C++.


Any sufficiently advanced bug is indistinguishable from a 
feature! ;)


-Wyatt


Re: Compile-time reflection and templates

2017-09-28 Thread Jacob Carlborg via Digitalmars-d

On 2017-09-27 21:47, Jean-Louis Leroy wrote:

I'd like to go further: find the template arguments 


There was a pull request that implemented this [1]. But it was closed, 
added to many new traits.


[1] https://github.com/dlang/dmd/pull/5201

--
/Jacob Carlborg