Skip to content

Conversation

@steveklabnik
Copy link
Contributor

The last two sections of the guide, and a small conclusion. I suck at conclusions.

I also realized I never covered strings, so I'm going to put that section up before we're actually 'done.'

src/doc/guide.md Outdated
Copy link

Choose a reason for hiding this comment

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

s/is is/is its

Copy link
Contributor Author

Choose a reason for hiding this comment

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

dammmit, thank you

@steveklabnik
Copy link
Contributor Author

@jakub- see if the extra words i added fixes your issue about the mutex.

src/doc/guide.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing *.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks

@steveklabnik
Copy link
Contributor Author

@jakub- thanks, fixed!

src/doc/guide.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is supposed to showcase the power of the macro system but it doesn't seem that way to me. It just looks like regex is implemented with macros rather than functions. With functions you could something like this where the returned structure has a function called is_match to test with.

let date_matcher = regex(r"^\d{4}-\d{2}-\d{2}$");
println!("{}", date_matcher.is_match("2014-01-01"));

Is it easy to show why it is much better implemented as a macro than a function? If so, this seems like a good place for it. Otherwise, the conclusion might be that it's another variant of a function but why should we care.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My point is mostly to show that macros exist, but it is true that it would be good to mention why it is implemented this way.

Copy link
Contributor

Choose a reason for hiding this comment

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

Discussing println! might be a good example? It does relatively complicated computation (compared to a C-like macro anyway), e.g. parsing & processing "{foo:<5.8t} {0:03d}", x, foo = y, and results in something that has a clear benefit: compile-time-checked flexible format strings.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good idea, especially since it's the macro we've been using already, and doesn't assume knowledge of something else, like regular expressions.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is assert! simple? It might be another alternative.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is an alternative, but it's not often used. At least, maybe assert_eq! or something would be better.

@steveklabnik
Copy link
Contributor Author

I've updated this PR to talk about println! instead of regexes. I like it better, but I'm unsure as to how much of a good idea it is to show the expanded output. I kinda like the shock-and-awe effect, heh.

src/doc/guide.md Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

s/numer/number/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i really, really, really need to figure out how to get my spell checker to not throw errors in code blocks, it's how i keep missing things like this

@mdinger
Copy link
Contributor

mdinger commented Aug 12, 2014

Much better macro intro.
Before - it was: "Macros do cool things but I'm not gonna show any of them to you"
Now - it's: "Macros are cool. Check this out!"

@steveklabnik
Copy link
Contributor Author

@mdinger awesome 😄

@steveklabnik
Copy link
Contributor Author

@huonw do you have anything to say here? You reviewed the initial draft.

@huonw
Copy link
Contributor

huonw commented Aug 14, 2014

I'll try to look over it again in the next day or so.

@steveklabnik steveklabnik force-pushed the guide_macros_and_unsafe branch from 1664a97 to b23fd8d Compare August 20, 2014 18:43
@steveklabnik
Copy link
Contributor Author

@brson : I reabased this to fix the merge error.

@steveklabnik steveklabnik force-pushed the guide_macros_and_unsafe branch from b23fd8d to 1395166 Compare August 20, 2014 22:41
@steveklabnik
Copy link
Contributor Author

@brson: sigh, the very last example doesn't work. I've fixed them both now.

@steveklabnik
Copy link
Contributor Author

(worth knowing, when we expand the macro, it throws a warning, heh.)

bors added a commit that referenced this pull request Aug 21, 2014
…rson

The last two sections of the guide, and a small conclusion. I suck at conclusions.

I also realized I never covered strings, so I'm going to put that section up before we're actually 'done.'
@bors bors closed this Aug 21, 2014
@bors bors merged commit 1395166 into rust-lang:master Aug 21, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants