News for hackers. Stuff that matters.
Re:Cppfront, Herb Sutter's proposal for a new C++ syntax by williamvds on Saturday September 17, 2022 @11:37AM (#32878362)
From a C/C++ programmer's POV those may look like GOTO labels, I agree. The proposed syntax is probably a consequence of a modern trend in using := for declaration and assignment.

    x := 5
Where you can optionally insert the type between the colon and equals, otherwise it is deduced

    x : int = 5
Re:Cppfront, Herb Sutter's proposal for a new C++ syntax by cvoss on Saturday September 17, 2022 @02:07PM (#32879748)
It's not modern at all. Type system notation has been using x : T to say "x has type T" for at least 50 years. It's the standard in academia, and has existed in real-world programming languages since 1971. [0]

[0] https://cstheory.stackexchange.com/questions/43971/why-colon...

Re:Cppfront, Herb Sutter's proposal for a new C++ syntax by forrestthewoods on Saturday September 17, 2022 @03:37PM (#32880729)
It is an old idea and also a modern trend. Trends come and go. It is currently trendy.

90s fashion is also trendy right now. Which is great because a few years ago it was 80. The cycle continues!

Re:Cppfront, Herb Sutter's proposal for a new C++ syntax by the_af on Saturday September 17, 2022 @08:03PM (#32882924)
"Currently trendy" how? Scala and Kotlin, to name just a few established programming languages, use the ": type" suffix style. They are neither "recent" nor from the original Algol era.
Re:Cppfront, Herb Sutter's proposal for a new C++ syntax by int_19h on Sunday September 18, 2022 @07:09PM (#32892351)
It depends on how you define "current", I suppose, but personally I'd consider Kotlin to be fairly recent.
Re:Cppfront, Herb Sutter's proposal for a new C++ syntax by the_af on Sunday September 18, 2022 @11:16PM (#32893907)
Well, Kotlin is from 2011 and Scala from 2004! 11 and 18 years ago, respectively. I'd say neither is recent by any reasonable sense of the word that would imply their syntax or conventions are "a current trend".
Re:Cppfront, Herb Sutter's proposal for a new C++ syntax by int_19h on Monday September 19, 2022 @08:16PM (#32905955)
11 years is not all that much for a PL, especially if you count from the date it was first announced, rather than from the first stable release (which for Kotlin was in 2016). For example, Rust started in 2006, and Rust 1.0 was in 2014, so it's actually older the Kotlin - but I think it still qualifies as "new", and many still consider it not fully battle-tested.

For another example, Python goes all the way back to 1991, with v1.0 in 1994. But it didn't really start to trend until early 00s.

Re:Cppfront, Herb Sutter's proposal for a new C++ syntax by the_af on Tuesday September 20, 2022 @04:52PM (#32917649)
> "11 years is not all that much for a PL"

Sure, if we redefine "recent" or "current" we can twist words to reach whatever conclusion. In reality, this ": type" syntax is neither new nor recent, nor is it "a current trend". Kotlin is also not recent. A decade is a lot.

You conveniently left Scala out, I suppose because it didn't fit your argument.

> "For another example, Python goes all the way back to 1991"

Well, since we are discussing Python, the syntax for its type hints looks like what exactly? And it was discussed as far back as 2014. Is that "recent"?

Re:Cppfront, Herb Sutter's proposal for a new C++ syntax by int_19h on Tuesday September 20, 2022 @04:59PM (#32917718)
If you look at the thread, I'm not the same person who originally made the claim.

Nevertheless, it is definitely the case that the "name: type" syntax is noticeably more trendy now than it was, say, 15 years ago. Sure, there were plenty of languages that had it already back then, including Scala (and ML, and Delphi, and ...). But how many of them were mainstream? Whereas now, this syntax is embraced by Python and TypeScript.

And not even OP claimed that the syntax itself is new or recent; I mean, everybody who knows about Pascal knows how old it really is! They literally said "it's an old idea" that is "currently trendy".

Re:Cppfront, Herb Sutter's proposal for a new C++ syntax by thechao on Saturday September 17, 2022 @12:15PM (#32878681)
I used to code for a language called "Spad" — originally shipped in 1972(?). The syntax:

    x : t = e
Was called "headform" and was the only syntactic form for the whole language. (Expressions used a shunting yard algorithm to desugar into a sequence of headform.)

The language included modules, classes, parameterics, functions, constraints, ..., whatever.

Re:Cppfront, Herb Sutter's proposal for a new C++ syntax by naruhodo on Saturday September 17, 2022 @09:31PM (#32883489)
Well, everything looks like a pile of dirt when the only tool you have is a Spad.

ducks

Re:Cppfront, Herb Sutter's proposal for a new C++ syntax by SaddledBounding on Saturday September 17, 2022 @01:42PM (#32879487)
> The proposed syntax is probably a consequence of a modern trend...

ML uses `name: type = value`. It came out over a decade before C++ and just one year after C.

Re:Cppfront, Herb Sutter's proposal for a new C++ syntax by teo_zero on Saturday September 17, 2022 @01:38PM (#32879436)
In English, the colon is used to separate a term to its definition, so it looks perfectly apt to mark declarations.

Besides, it makes it trivial for text editors to implement "go to definition", and many other niceties without a real semantic parser.

Re:Cppfront, Herb Sutter's proposal for a new C++ syntax by dvratil on Saturday September 17, 2022 @01:18PM (#32879244)
I don't think this has anything to do with modern trends - := is a formal way of writing assignment (the widely used = is actually an equality sign), and has already been present in Pascal for decades (and other languages as well).
Re:Cppfront, Herb Sutter's proposal for a new C++ syntax by Jtsummers on Saturday September 17, 2022 @01:33PM (#32879401)
https://en.wikipedia.org/wiki/ALGOL_58

ALGOL, the := in programming languages used for assignment comes from IAL which became ALGOL 58. It's definitely not a modern development. Go reintroduced it to popular mainstream languages, sort of. Except they still use = for assignment and := is used when it's also declaring a new variable.

Re:Cppfront, Herb Sutter's proposal for a new C++ syntax by int_19h on Sunday September 18, 2022 @07:13PM (#32892365)
:= for assignment ultimately comes from math, as do most operators in early Algol: https://www.masswerk.at/algol60/report.htm#2_3
Re:Cppfront, Herb Sutter's proposal for a new C++ syntax by noobermin on Saturday September 17, 2022 @02:45PM (#32880158)
All the replies are missing something, does cpp2 have goto labels? What happened to them.

Unless you now have named loops in modern C++ now this removing goto is problematic.

Re:Cppfront, Herb Sutter's proposal for a new C++ syntax by rafram on Saturday September 17, 2022 @01:23PM (#32879284)
I’m not sure I’d := is a “modern trend.” Smalltalk had it circa 1972, but none of the modern-day hip languages I can think of do. Your latter example is a common syntax, but the colon is omitted with the type in most languages (TypeScript, Rust, etc.).
Re:Cppfront, Herb Sutter's proposal for a new C++ syntax by charcircuit on Saturday September 17, 2022 @02:45PM (#32880159)
X being a modern trend does not mean it was not done in the past. It doesn't mean that it hasn't trended in the past either.
Re:Cppfront, Herb Sutter's proposal for a new C++ syntax by the_af on Saturday September 17, 2022 @08:04PM (#32882937)
So what does it mean then?

It was done in the very distant past. It was done in the intervening time. And it's done now. "Modern" trend?