-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Figure out what string interpolation syntax should be #11
Comments
str = "#{Variable} not variable" my $str = "This is $interpolated"; str = "Python's is dumb %(name)s." % variable |
More importantly, there should be literal string and interpolated string. Either we need to use an inline glif or a format function. It's really up to which way we fall in that case. |
Mustache/Handlebars-style interpolation as a language feature.
|
One moment, let me summon my knowledge thus far... implementation of mustache w/o iterating over array/list structures...
And let me tell you about how much I love language features implemented in the language itself. |
@zellio's right. We're going to need some sort of distinction between interpolated strings and string literals. At least in the first round of the compiler, we (probably) won't be able to handle unicode in interpolated strings, since the compiler will have to do string manipulation on them, and OCaml has pretty bad unicode support. I really like the ability to just format strings without any sort of format function, because it's pretty, but that will require we have something special like On the other hand, a format function could be part of the String class, and reduce this to a simple function call such as Opinions? |
We could do what Ruby does, and have single- and double-quoted strings, where only double quoted strings support interpolation and character escapes. |
I like my option (with a function on String). Explicit interpolation all the way~ |
@nicolasmccurdy right now |
I like the ruby style of explicit interpolation via the quoting character. (Which, we could implement by calling an internal function of the String object). It should search it's current scope for variables though. I strongly dislike
|
We can do characters as |
@zellio Lol, no Lisp chars plz |
If we have macros (as I'm really really hoping we can do) the |
@zellio I don't like doing automatic binding to scope variables, as it makes it so I can't pass around partially formatted strings, since the formatting is coupled to the scope the format literal was created in. @toroidal-code If you want to support unicode at some point in the future, you can save work now by nixxing the concept of a 'Char' entirely and acknowledging it as a single length string. A 'Character' is vague and character-set dependent. Character set information can be included with a String - a string is a heavyweight thing. you use chars when you want something lightweight, but once you start including charset meta-information it becomes just as heavy. |
@weswigham Brick's |
Meh, refer to following. Old information is old. |
Distinguishing between a I also hate having to distinguish between '' and "" literals inside my editor - If I typed |
Most of my reasoning is because it's more useful to thing of a |
I'm kinda with @weswigham on this whole @weswigham - doesn't mean you can't have them look to scope when it's not provided in the format args |
@zeillio That just seems like an absolutely terrible idea from a security standpoint... If I take in user input and it contains '{{varname}}' and apply my scope to it, they can discover things I haven't explicitly disclosed. |
@weswigham - why would you blindly interpolate user input? that's a horrendous idea |
@zellio from a syntax perspective there's no need for @weswigham You shouldn't be using eval. There's safe_eval for that. (lol python) |
|
I don't think |
@weswigham - I'm still confused as to why you are interpolating user input.
|
Alright, so |
So I'm for having |
Okay. So what's the interpolation going to look like in the string? We have to remember that only things that implement the ToStr trait will be able to be embedded in strings. |
Why not use printf-style interpolation? It's very widely known. |
Or |
@nicolasmccurdy the problem with printf style interpolation is that printf is required to take a variable number of arguments depending on the content of the string. And that's a bit gross. |
Whereas handlebars-type/rust-type format take one argument, and is, at its simplest, simply recursively called with partially parsed tokens. |
@nicolasmccurdy why? My vote is for Mustache or Ruby style |
@kristenmills and @nicolasmccurdy - I think having something akin to Should we format when we interpolate? |
@zellio - I don't think we should format when we interpolate. I agree formatting is a nice thing to have but I think we should take a similar approach to ruby and separate formatting from basic interpolation. |
@kristenmills Good point, I think that would make things simpler. And there could still be printf-style methods like how Ruby does it. |
I would rather have interpolation and formatting separate. I would prefer a post-processing method or macro to handle formatting, the way Rust or Python (minus the |
Templating, as with handlebars, handles both of those concerns.
Which when invoked with |
@kristenmills @nicolasmccurdy @toroidal-code - agreed, to recap Interpolation syntax ( "This is a string {{which}} interpolates"
'This is a string {{which}} wont' |
We really need this
I don't want c/c++
The text was updated successfully, but these errors were encountered: