News for hackers. Stuff that matters.
Re:Lily Programming Language by berdario on Friday July 01, 2016 @09:44AM (#12015943)
Swift string interpolation syntax is not more awesome or any less ambiguous than other syntaxes used in other languages

In fact, it's the first time that I've seen interpolation with round parentheses, rather than curly braces (which are used in javascript with $ (es2015 template literals), python, bash with $, ruby with #, groovy with $, etc... )

> LoL. Refcounting can lead to just as long pauses as GC

He didn't say more performant, he said consistent

Re:Lily Programming Language by vorg on Friday July 01, 2016 @07:50PM (#12020542)
> I don't understand why anyone would still require special notation for interpolated strings, when we have the awesome and unambiguous string interpolation syntax introduced by Swift

You're both wrong. String interpolation is just a very thin syntactic layer. It's easy enough to write

  printf("Half of %f is: %f5.2", someVal, someVal * 0.5)
instead of

  print("Half of $someVal is: ${someVal * 0.5}")
and a lot easier for a programming language to parse, without needing to feed the parser into the lexer. And you also get easy formatting of the decimal (e.g. %f5.2), whereas string interpolation (in Swift, Apache Groovy, etc) requires a separate call, e.g.

  print("Half of $someVal is: ${format(someVal * 0.5, "%f5.2")}")
Re:Lily Programming Language by drjeats on Saturday July 02, 2016 @01:16AM (#12021458)
C#'s new interpolation syntax is a counterexample to your point about easy formatting:

https://msdn.microsoft.com/en-us/library/dn961160.aspx#Ancho...

    $"Name = {name}, hours = {hours:hh}"
    var s = $"hello, {name}"
    System.IFormattable s = $"Hello, {name}"
    System.FormattableString s = $"Hello, {name}"
    $"{person.Name, 20} is {person.Age:D3} year {(p.Age == 1 ? "" : "s")} old."
Re:Lily Programming Language by tomp on Friday July 01, 2016 @09:52AM (#12015994)
(1) It's obviously less ambiguous, because you can't do it accidentially; "\(" is an invalid escape, whereas "${1}" or "$a" is a valid string (i.e. you could write it without meaning to interpolate the variables).

(2) It's only consistent if you always know what your pointers are pointing at, and whether your pointers are the last reference to it... but then you can just use delete, right?

Re:Lily Programming Language by berdario on Friday July 01, 2016 @10:44AM (#12016403)
(1) you're confusing C string and other languages strings (even Swift strings are not the same thing as NSString or C strings). Anyhow, even in C \( is perfectly accepted by compilers

    gcc -Wall -x c - <<EOF
    #include <stdio.h>
    int main(){ printf("\(hi"); }
    EOF
So it's perfectly reasonable to write it and not mean interpolation (maybe they meant "\\(", but that's another matter)

(2) A sequence can be sorted without you knowing which elements are inside it, A computation can be known to terminate without you knowing (yet) which value it will yield.

Similarly, you don't need to have internal knowledge of your code to know that you'll be able to rely on RC consistency in the future (otoh I guess that something consistent is not necessarily the same as something predictable)

Re:Lily Programming Language by hk__2 on Friday July 01, 2016 @06:46PM (#12020239)
> Anyhow, even in C \( is perfectly accepted by compilers

Even if it’s accepted it’s not valid, at least in the C99 standard.