ubsan: sorry, never had a chance to get back on IRC yesterday, what's up?
Leo` joined the channel
Leo`
nmatsakis: Ping. I'm discussing with pnkfelix right now and we have questions about macro stuff.
nmatsakis
ok
Leo`
First question: is nrc the primary person for macros 2.0 (as in ‶rewrite-rules-based macros″, not procedural ones).
s/./?/
nmatsakis
Leo`: yes
he's been doing the most thinking about it
eddyb
and writing the RFCs
nmatsakis
I think we've largely retrenched to macros 1.1 in terms of short term :)
but i guess that's more about procedural
Leo`
Ok. :D Next question: do you know off-hand if he's planning on keeping non-terminals like expr, ty, etc, or just have token-tree based macros only?
eddyb
I would love to just ha e a general-purpose $foo but that's not really possible
Leo`
What do you mean?
eddyb
Leo`: many current macros you couldn't translate
nmatsakis
Leo`: Hmm; I don't think anybody has proposed removing non-terminals, but I also don't know that he has put that much thought into this aspect
I think we've been thinking more about hygiene
Leo`
Mh ok.
nmatsakis
and esp. hygiene for things other than local variable names
but I could be wrong
Leo`
We're asking because I'm concerned that macros 2.0 does not make the same mistakes that macro-rules have regarding future-proofing, thuis kind of stuff.
eddyb
one thing I had in mind is "scan until you find the token after the $foo"
i.e. so ($x; $y; $z) could take expressions, because they don't contain ;
Leo`
eddyb: That's basically expressible with regular expressions I guess... ?
[^;]*
:P
eddyb
with delimited sequences it's *almost* okay
nmatsakis
Leo`: it's a good point!
eddyb
but now if you do ($x, $y, $z)
and pass foo::<a, b>, c
nmatsakis
Leo`: that's an argument in favor of a "macros 2.0" that I hadn't fully considered
eddyb
you get them split between "foo::<a" and "b>"
nmatsakis
yeah, sadly `<` and `>` is one of the things that just makes this plain hard
Leo`
eddyb: Yeah < > are not considererd delimited tts by the parser.
eddyb
maybe this is indicative of just how bad <> are
Leo`
Yup.
eddyb
and it would work otherwise
not 100% sure though
nmatsakis
though you could certainly imagine
schemes where you tell the parser how to treat them
eddyb
you also can't capture individual tokens this way
nmatsakis
e.g., "type-like"
or "expr-like"
Leo`
That also falls outside the expressivity of regular-expressions.
nmatsakis
basically i'm imagining nonterminals
but not tied to the current grammar per se
eddyb
nmatsakis: I sort of want the $foo system to be expanded in a way that you can delegate to other macro_rules macros
nmatsakis
yes, I've seen some work in the context of Racket
eddyb
not sure what exactly it should do though
nmatsakis
where you can write more of a grammar
Leo`
nmatsakis: pnkfelix is recommending me to have a meeting with nrc to discuss this, would you be interested in participating as well?
nmatsakis
Leo`: possibly :) I saw talk to him about it, let me know when it is
*say
otherwise I'll just pick your brains later
Leo`
Ok ok.
ubsan
nmatsakis: boop
nagisa_ has quit
nmatsakis
ubsan: what's up
ubsan
nmatsakis: I want to talk about casts
and something else
nmatsakis
ok
ubsan
let me check
oh, right, and transmute_copy
arielby
ok
ubsan
so, first transmute_copy, because I think it's a simpler thing
basically, I think the function would be more useful if it took <T: ?Sized>
arielby
ubsan: transmute_copy is just ptr::read
why do we even have it as a function?
ubsan
arielby: because it is a function now
arielby
ubsan: yeah stability
but
ubsan
because someone thought it was a good idea to stabilize
also, it's not ptr::read
arielby
ubsan: no
ubsan
it's memcpy
arielby
because it was present since 1.0.0
pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
ptr::read(src as *const T as *const U)
}
nothing more
nothing less
ubsan
because otherwise, that would be hella UB
well
fun
I'm fairly certain that's hella UB, unless ptr::read for some reason doesn't take an aligned parameter
arielby
ubsan: transmute_copy requires alignment
ubsan
arielby: why?
arielby
because it is ptr::read
ubsan
like, why should we do that?
arielby
we should have `ptr::unaligned_read`
or something
if we want an unaligned read API
ubsan
I disagree
arielby
unaligned read vs. aligned read
is orthogonal to random casts
ubsan
transmute_copy should just memcpy
nmatsakis
so... why is that UB? It seems to me that it... may be UB?