Skip to content

Comments

Add example from the DLang Tour to the example roulette#1755

Merged
dlang-bot merged 1 commit intodlang:masterfrom
wilzbach:add-examples
Jul 20, 2017
Merged

Add example from the DLang Tour to the example roulette#1755
dlang-bot merged 1 commit intodlang:masterfrom
wilzbach:add-examples

Conversation

@wilzbach
Copy link
Contributor

Full credit for this example goes to @JackStouffer dlang-tour/english#137 - I merely reformatted it and added @nogc to prove the point ;-)

While adding the example, I realized that the existing roulette mechanism was broken.

CC @CyberShadow @ZombineDev

index.dd Outdated
)
$(EXTRA_EXAMPLE
----
void main()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a short comment at the top describing what the program is doing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment should be before main - perhaps even a ddoc comment.

@CyberShadow
Copy link
Member

Would be nice to avoid the example switching after the page loads.

Could be done by forcing the JavaScript to print a random example as the page loads (using document.write), and having a fallback in a <noscript> tag.

@wilzbach
Copy link
Contributor Author

Needs a short comment at the top describing what the program is doing.

Ok. Added.

Would be nice to avoid the example switching after the page loads.
Could be done by forcing the JavaScript to print a random example as the page loads (using document.write), and having a fallback in a tag.

Yeah I don't like the current solution either. Will make a PR with something smarter ;-)

@CyberShadow
Copy link
Member

CyberShadow commented Jun 21, 2017

This example would be a good deal more exciting if all of main was @nogc... as it is, the lambda literal is going to be incomprehensible to most people not familiar with the language.

Perhaps it's better to just drop the lambda literal and only leave the comment.

@andralex What do you think? I think you would like to review all new non-trivial front page changes anyway.

@PetarKirov
Copy link
Member

I think it would be nice to have a drop down, like on the golang page. I remember back some time ago when I wanted to show one particular example to a friend that I had to reload the page a couple of times to get to it.

@andralex
Copy link
Member

The example is fine. Would be great to have a little button somewhere "Another" that loads another random example. Also examples should have nice titles such as "Sort", "Find min and max", etc.

index.dd Outdated
)
$(EXTRA_EXAMPLE
----
void main()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment should be before main - perhaps even a ddoc comment.

index.dd Outdated
int[] arr3 = [6, 8, 3];
// @nogc functions are guaranteed by the compiler
// to be without any GC allocation
() @nogc {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nogc would indeed be best in main

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, of course, but this depends on writefln (or similar) to be @nogc ...
And the assumeNoGC hack seemed to ugly for a frontpage example.

@CyberShadow
Copy link
Member

Would be great to have a little button somewhere "Another" that loads another random example.

#1777

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @wilzbach!

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.

@wilzbach wilzbach force-pushed the add-examples branch 2 times, most recently from 460fb43 to 237dd08 Compare July 2, 2017 00:05
@wilzbach
Copy link
Contributor Author

wilzbach commented Jul 2, 2017

Would be great to have a little button somewhere "Another" that loads another random example.

As #1777 has been merged & deployed, I rebased this PR.

Also examples should have nice titles such as "Sort", "Find min and max", etc.

#1777 implies this ;-)

@wilzbach
Copy link
Contributor Author

wilzbach commented Jul 4, 2017

Ping @CyberShadow - I think we are all set here :)

@wilzbach
Copy link
Contributor Author

Ping @CyberShadow - I think we are all set here :)

Rebased -> should be good to go (it has even been approved by Andrei).

@CyberShadow CyberShadow self-assigned this Jul 20, 2017
@CyberShadow
Copy link
Member

Looks like you need to rebase.

@wilzbach
Copy link
Contributor Author

Looks like you need to rebase.

That was weird - rebase worked without interaction on my machine ...

@dlang-bot dlang-bot merged commit b1cd228 into dlang:master Jul 20, 2017
@wilzbach wilzbach deleted the add-examples branch December 18, 2017 06:01
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