-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
More hints? : / #126
More hints? : / #126
Conversation
More of a feedback: **DON'T MERGE** I tried finding out the type of `take(...)` with `writeln(typeof(fib10));` -> `Error: cannot pass type Take!(FibonacciRange) as a function argument`. I always find the danger of `auto` to be that it's not very well perceivable what is going on, or what type is going to be returned. It's just bad for understanding : (. Also, suddenly things like `x!y(z)` appear. I "believe" it has something to do with templates. But I'm really not sure. It would be great if it was introduced before using it (note: the `!` was already used in https://tour.dlang.org/tour/en/basics/alias-strings ). I struggle with the solution: ``` bool empty() const @Property { // So when does the Fibonacci sequence // end?! return this.length == 0; } void popFront() { return this[1..$]; } int front() @Property { int fibbi; while(!this.empty()) { fibbi += this[0]; this.popFront(); } return fibbi; } ``` I somehow assume the struct to be an array (or a sequence). But it makes no sense at all. Also, what is `@property` for? It would also help to mark exactly where could should be added. Otherwise I feel like I should maybe adjust whatever.. I now assumed that I only need to realize the functions of the struct. Am I missing something? So, I guess I haven't yet understood ranges : P... Maybe we can somehow figure out what information is missing so it's "idiot-proof" (which is almost true as I'm a programming goof).
Progressing through the tour I now am at Templates which clears up the |
To achieve what you want, you actually want to do one of two things // prints during compilation
pragma(msg, typeof(fib10));
// or during run time
writeln(typeof(fib10).stringof);
Yeah, that should probably be removed. Could you please link me to the page were you got this example? |
I assume from one of these page: http://tour.dlang.io/tour/en/basics/ranges
http://tour.dlang.io/tour/en/gems/attributes
http://tour.dlang.io/tour/en/gems/opdispatch-opapply
|
Thanks a lot for your feedback. Is there anything else you dislike or think that could be improved? |
Closing this PR due to inactivity. As mentioned feedback via issues is welcome. |
More of a feedback: DON'T MERGE
I tried finding out the type of
take(...)
withwriteln(typeof(fib10));
->Error: cannot pass type Take!(FibonacciRange) as a function argument
. I always find the danger ofauto
to be that it's not very well perceivable what is going on, or what type is going to be returned. It's just bad for understanding : (.Also, suddenly things like
x!y(z)
appear. I "believe" it has something to do with templates. But I'm really not sure. It would be great if it was introduced before using it (note: the!
was already used in https://tour.dlang.org/tour/en/basics/alias-strings ).I struggle with the solution:
I somehow assume the struct to be an array (or a sequence). But it makes no sense at all. Also, what is
@property
for?It would also help to mark exactly where code should be added. Otherwise I feel like I should maybe adjust whatever.. I now assumed that I only need to realize the functions of the struct. Am I missing something?
So, I guess I haven't yet understood ranges : P... Maybe we can somehow figure out what information is missing so it's "idiot-proof" (which is almost true as I'm a programming goof).