Skip to content

Comments

Improve spec/function#lazy-params example#2459

Merged
wilzbach merged 2 commits intodlang:masterfrom
PetarKirov:improve-lazy-param-example
Jan 12, 2019
Merged

Improve spec/function#lazy-params example#2459
wilzbach merged 2 commits intodlang:masterfrom
PetarKirov:improve-lazy-param-example

Conversation

@PetarKirov
Copy link
Member

To better showcase the D's expressiveness.

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @ZombineDev!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

@PetarKirov PetarKirov force-pushed the improve-lazy-param-example branch from 24369b4 to 39b3160 Compare August 31, 2018 10:57
@PetarKirov
Copy link
Member Author

PetarKirov commented Nov 10, 2018

@jacob-carlborg @thewilsonator can you guys help me debug the ddoc failure? I tried various things locally ~2 months ago, but it always seemed to fail for no reason.

@thewilsonator
Copy link
Contributor

this is using SPEC_RUNNABLE_EXAMPLE_COMPILE which I have just discovered in #2507 wraps a void main(){ ... } around the example. so that code becomes

void main()
{
    import std.stdio : writeln;

    void main()
    {
        int x;
        3.times(writeln(x++)); // <<< fails here
        writeln("-");
        writeln(x);
    }

    void times(int n, lazy void exp)
    {
        while (n--)
            exp();
    }
}

which for me fails with Error: no property times for type int, presumably because times is nested. Whats with all the LaTeX failures, I have no idea. Maybe it confuses the macros. Either way it doesn't look like you will be able to show off 3.times(writeln(x++)); with SPEC_RUNNABLE_EXAMPLE_COMPILE , you'd have to do a no main wrapping version.

@PetarKirov
Copy link
Member Author

Thanks for looking into this @thewilsonator. Actually I had gotten only so far as the LaTeX problems and I haven't even considered the the problem with SPEC_RUNNABLE_EXAMPLE_COMPILE. I propose we add SPEC_RUNNABLE_EXAMPLE_COMPILE_CUSTOM_MAIN version which would not try to wrap the code in another main(). I'll see if that's easy to do when I have some free time on my hands.

@wilzbach
Copy link
Contributor

I propose we add SPEC_RUNNABLE_EXAMPLE_COMPILE_CUSTOM_MAIN version which would not try to wrap the code in another main(). I'll see if that's easy to do when I have some free time on my hands.

Please don't. The script already checks for void main. Better to fix that, but looking on this from my phone I don't think that's the root cause. We have had tons of problems with the function page getting too big and thus LaTeX throwing weird errors.

@thewilsonator
Copy link
Contributor

The script already checks for void main.

Good to know

Better to fix that, but looking on this from my phone I don't think that's the root cause. We have had tons of problems with the function page getting too big and thus LaTeX throwing weird errors.

Ahh, right.

PetarKirov and others added 2 commits January 11, 2019 11:25
@wilzbach wilzbach force-pushed the improve-lazy-param-example branch from 178bd77 to cca5fad Compare January 11, 2019 10:51
@wilzbach
Copy link
Contributor

It could be related to the - and LaTeX not liking it (though I can't build the PDF at the moment either), but I tested this commit here.

@wilzbach wilzbach merged commit 23832d8 into dlang:master Jan 12, 2019
@PetarKirov PetarKirov deleted the improve-lazy-param-example branch January 14, 2019 00:20
@PetarKirov
Copy link
Member Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants