4 ms·
Looks like the named string expressions e.g. \{p.Age} were inspired by Swift's \(p.Age)
by sgt 12y ago
Looks like the named string expressions e.g. \{p.Age} were inspired by Swift's \(p.Age)
- skrebbel 12y agoMaybe, but they changed the syntax again (read the italic parts in the article)
- jkrems 12y agoSyntax like `${x}` inside of string literals has been around a lot longer than Swift and is about as close to `\{p}`. I would be surprised if Swift has anything to do with it.
- DrJokepu 12y agoTo be fair, I don't think I have ever seen the escape sequence syntax being used for string interpolation before Swift.
- bronxbomber92 12y agoScala had it before Swift: http://docs.scala-lang.org/overviews/core/string-interpolation.html http://docs.scala-lang.org/overviews/core/string-interpolati... (implemented with as a macro AFAIK)
- copsarebastards 12y agoJesus Christ, if you people are going to argue about something as silly as which language had a minor feature first, maybe spend some time learning about programming languages first? Python and Ruby have had equally sophisticated string interpolation since before Scala existed. Perl has had similar string interpolation features for at least 20 years. And it wouldn't surprise me if lisp did it before Perl.
- klibertp 12y agoYou were downvoted - it seems - just because. Or maybe someone felt offended by your mention of a fictional character. Whatever. More to the point: feature known as string interpolation is really, really old. And popular. Just go here: http://rosettacode.org/wiki/String_interpolation_%28included%29 http://rosettacode.org/wiki/String_interpolation_%28included... and see for yourself. TCL is from 1988, for example, which predates Scala quite a bit. Oh, and also predates Swift. Yeah, I'd like people who comment on language features to study PL design history a tiny little bit more.
- copsarebastards 12y agoIgnorance doesn't annoy me--if anything, it's exciting, because there's so much people can learn. What annoys me is that people buy into so much hype around languages that are mediocre at best.
- jkrems 12y agoMy example was from shell string interpolation/`sh`, which predates TCL by more than a decade. Not sure where your "I'd like people to study PL design history" comes from. It sounds kind of pretentious tbh. We were looking for popular languages that use a syntax similar to `\{x}` for string interpolation. TCL uses a dollar sign, so pretty much as far from the C# syntax as possible (inside of the limited syntactical range out there). At least this page does not list any language that uses the same syntax: http://rosettacode.org/wiki/String_interpolation_%28included%29 http://rosettacode.org/wiki/String_interpolation_%28included.... But maybe your vast knowledge of PL design history can provide information on one that does?
- jkrems 12y agoThe actual "discussion" was not about who invented string interpolation (I was talking about shell/`sh` string interpolation btw. which predates Python, Perl, and Ruby). It was about who they "copied" the syntax from since using a backslash as opposed to a dollar or a hash sign isn't quite as common. And none of the languages, including Scala, mentioned here uses that exact syntax. It's just an attempt to trace back syntax decisions to where the authors of the language might have seen it. Fun and games - lighten up. ;)
- jkrems 12y agoGood point. But my assumption would be that backslash was chosen because it's a reserved sequence that didn't have a meaning yet. E.g. they could have started suddenly treating "It costs $x, where x is the number of rides" as a compile time error when it previously was a perfectly valid string literal. And not everyone wants to introduce yet another string literal syntax like ES6 does with backticks...
- CmonDev 12y agoI hate to break it to you, but there is literally nothing in this world inspired by Swift (yet). The language is simply too new and too derivative. Quite "innovative" for Apple dev world, though.
- bjz_ 12y agoRust recently added `if let` bindings, specifically inspired by Swift. But apart from that I agree.