Stream: cranelift

Topic: ISLE: `#t`/`#f` vs `$true`/`$false`


view this post on Zulip kmeakin (Aug 20 2024 at 14:16):

What's the difference between the #t/#f syntax and $true/$false? The former is listed in the ISLE language specification, but the latter is used in the ISLE opt/lower rules

view this post on Zulip Chris Fallin (Aug 20 2024 at 14:22):

#t and #f are built into the language and compile to constant 1 and 0 in Rust. I don't think we use them anywhere, they're an artifact of the early ISLE compiler prototype where we didn't really know how the language would be used in detail yet, and we can probably remove them. $true and $false are a slight abuse of the $ syntax, which was meant to propagate through symbolic constants to the generated Rust code (and happens to work for Rust keywords like true and false); this caught on, it looks better than the Scheme-style #t/#f, and we might as well keep using it. The semantic difference I guess would be the types: integer vs. bool

view this post on Zulip kmeakin (Aug 20 2024 at 14:26):

Ah so $ident are pattern aliases but are opaque to the ISLE compiler?

view this post on Zulip Chris Fallin (Aug 20 2024 at 15:31):

I'm not sure exactly what you mean by "pattern aliases" but yes, they're opaque tokens just passed through

view this post on Zulip kmeakin (Aug 20 2024 at 15:32):

I mean like how in rust you can use const FOO: usize = ... in a pattern

view this post on Zulip Chris Fallin (Aug 20 2024 at 15:36):

ah, sure; except it's a little more general in the sense that it works in expression context (rule right-hand sides) too


Last updated: Nov 22 2024 at 16:03 UTC