trill-lang / trill

A type safe, compiled language inspired by (and written in) Swift
MIT License
275 stars 15 forks source link

Support for string interpolation #47

Closed segiddins closed 7 years ago

segiddins commented 7 years ago

Probably the biggest challenge will be in the lexer, but this would be very cool

harlanhaskins commented 7 years ago

100% down for this.

The question of syntax...

harlanhaskins commented 7 years ago

I'm thinking maybe bash-style, where you can do a simple variable substitution with a $, or a complex expression in $()

harlanhaskins commented 7 years ago
let a = 10
let s = "a: $a, a+1: $(a+1)"

Or just take Swift's, which I'm also absolutely cool with.

segiddins commented 7 years ago

My only issue with allowing "$foo" to interpolate foo is that it doesn't necessarily pass visually as a substitution, especially without syntax highlighting (balanced delimiters are really really cool)

harlanhaskins commented 7 years ago

Yeah I think you're right. Then the question becomes if we use $() or \()

I think if that's the option, I prefer \() because my eyes scan it as an escape sequence.

segiddins commented 7 years ago

String interpolation is implemented as of #52 !