string-interpolation

aliasing a method results in different objects?

def foo "foo" end alias foo2 foo puts "foo2: " + foo2.object_id.to_s puts "foo: " + foo.object_id.to_s In the above example, I expected to see the same object_id output for each method call since they reference the same method. Why do I see different object_id's? When you alias a method in Ruby doesn't the alias refer to the origi...

Interpolation and templating

I am trying to verify my understanding string interpolation and string templating. Is it correct to say that the two Java code snippets are examples of templating? public class Person { //showing only relevant code public String toString() { return "Name: " + name + " salary: " + salary + " address: " + address; } } public S...

Why is this intended interpolation interpreted as division by Perl?

G'day, Why am I getting the following two errors from the script fragment below? Argument "www4.mh.xxxx.co.uk.logstatsto20090610.gz" isn't numeric in division (/) at line 56 Argument "/logs/xxxx/200906/mcs0.telhc/borg2" isn't numeric in division (/) at line 56 The variables $dir and $log are both strings and the concatenation...

Parsing string interpolation in ANTLR

I'm working on a simple string manipulation DSL for internal purposes, and I would like the language to support string interpolation as it is used in Ruby. For example: name = "Bob" msg = "Hello ${name}!" print(msg) # prints "Hello Bob!" I'm attempting to implement my parser in ANTLRv3, but I'm pretty inexperienced with using ANTLR...

Java Expression Language : Interpolation?

Greetings, In the webapplication I am developing , I want to do something like follows: I Have a Bean like class Gene{ String geneid; String sequence; .. } // EL expression (sometimes should be simple as "${geneid}" without URL pattern) String exp="<a> href='http://www.ncbi.nlm.nih.gov/pubmed?term=${geneid}' />"; String outputString=...

python string interpolation

What could generate the following behavior ? >>> print str(msg) my message >>> print unicode(msg) my message But: >>> print '%s' % msg another message More info: my msg object is inherited from unicode. the methods __str__/__unicode__/__repr__ methods were overridden to return the string 'my message'. the msg object was initiali...

Is it possible to temporarily disable Python's string interpolation?

I have a python logger set up, using python's logging module. I want to store the string I'm using with the logging Formatter object in a configuration file using the ConfigParser module. The format string is stored in a dictionary of settings in a separate file that handles the reading and writing of the config file. The problem I ha...

How can I manually interpolate string escapes in a Perl string?

In perl suppose I have a string like 'hello\tworld\n', and what I want is: 'hello world ' That is, "hello", then a literal tab character, then "world", then a literal newline. Or equivalently, "hello\tworld\n" (note the double quotes). In other words, is there a function for taking a string with escape sequences and returning an eq...

Can Perl string interpolation perform any expression evaluation?

related to question: http://stackoverflow.com/questions/3939788/perl-regex-substituion/3939854 In Perl, is there a way like in Ruby to do: $a = 1; print "#{$a + 1}"; and it can print out 2? ...

Can I use Razor (or similar) in a regular .NET class, i.e. get string interpolation of sorts?

I could've sworn I saw some articles a while ago about imperfect but useful string interpolation methods for C, but no such luck right now. However, there's Razor, which does more or less what I want. Suppose you have a database client application with tickets, and e-mail notifications are to be sent whenever tickets get created, signif...