Skip to content
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

Closed
wants to merge 1 commit into from
Closed

More hints? : / #126

wants to merge 1 commit into from

Conversation

Timoses
Copy link
Contributor

@Timoses Timoses commented Nov 29, 2016

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

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).
@Timoses
Copy link
Contributor Author

Timoses commented Nov 29, 2016

Progressing through the tour I now am at Templates which clears up the ! usage pattern. I suppose a hint that templates will be dealt with later could be useful. Although the usage does confuse without any knowledge of templates beforehand.

@JackStouffer
Copy link
Contributor

I tried finding out the type of take(...) with writeln(typeof(fib10)); -> Error: cannot pass type Take!(FibonacciRange) as a function argument

writeln isn't capable of writing it because it's not an actual value. int is not a valid function parameter for example.

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

Also, what is @Property for?

Yeah, that should probably be removed. Could you please link me to the page were you got this example?

@wilzbach
Copy link
Member

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

17:        @property empty() const;
50:    bool empty() const @property 
60:    int front() @property

http://tour.dlang.io/tour/en/gems/attributes

9:### `@property`
11:A function marked as `@property` looks like
15:        @property bar() { return 10; }
16:        @property bar(int x) { writeln(x); }

http://tour.dlang.io/tour/en/gems/opdispatch-opapply

89:    @property
94:    @property

@wilzbach
Copy link
Member

Although the usage does confuse without any knowledge of templates beforehand.

Thanks a lot for your feedback.
I created an issue to track the progress:

#134

Is there anything else you dislike or think that could be improved?
Issues and PRs are welcome ;-)

@wilzbach
Copy link
Member

wilzbach commented Jun 5, 2017

Is there anything else you dislike or think that could be improved?
Issues and PRs are welcome ;-)

Closing this PR due to inactivity. As mentioned feedback via issues is welcome.

@wilzbach wilzbach closed this Jun 5, 2017
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants