Bug 471279 - String interpolation
Summary: String interpolation
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Golo (show other bugs)
Version: unspecified   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: investigate
Depends on:
Blocks:
 
Reported: 2015-06-29 04:44 EDT by Julien Ponge CLA
Modified: 2016-05-25 10:27 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Julien Ponge CLA 2015-06-29 04:44:37 EDT
(from https://github.com/golo-lang/golo-lang/issues/14)

String interpolation is a nice feature found in modern languages, such as the following in Ruby:

name = "world"
str = "Hello #{name}!"

------ Daniel Petisme commented:

Oups, Sorry for the duplication. I copyNpaste
Let's interpole embeded expressions within a String.
Here's a sample test

//Given
let answer  = 42
let what = "answer"

//When 
let sentence = "The ${what: toUpperCase()} is ${answer}"

//Then 
require(sentence == "The ANSWER is 42")
I think the variable interpolation is not that hard (IMHO) where an expresion could be tricky. Maybe we have to split this Specification in 2 (variable & expression)

Regarding the syntax, I dunno care. $ is the historical variable prefix (shell) but any symbol suit fine (Eg. #).

The brackets could be optionnal for variable but mandatory for expressions.

------ Guillaume Grossetie commented:

I'm interested to work on this issue but I have no clue how ? I think I need to understand the JJT https://github.com/golo-lang/golo-lang/blob/master/src/main/jjtree/Golo.jjt ?

And also in PHP : https://java.net/downloads/javacc/contrib/grammars/php.jj :wink: