Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

mystes posted:

Randomize the date format on startup.

phew at least we got one posser talking some sense

Adbot
ADBOT LOVES YOU

animist
Aug 28, 2018

Carthag Tuek posted:

dates, times, & strings should only be initializable with full metadata (calendar, timezone, encoding, etc). otherwise you just invite badness

if you have a lot of those kinds of values, syntactic sugar is not a help. you need to parse that poo poo systematically or youre gonna gently caress up

:hmmyes:

i'd allow an exception for reading the system clock / current GMT but even that shouldn't be displayable without metadata, you should just be able to subtract it for timing purposes

Soricidus
Oct 21, 2010
freedom-hating statist shill

animist posted:

:hmmyes:

i'd allow an exception for reading the system clock / current GMT but even that shouldn't be displayable without metadata, you should just be able to subtract it for timing purposes

if you’re timing things then you probably don’t want time of day anyway, and the high precision monotonic clocks you want to be using deliberately don’t have a defined start time to prevent people mixing things up.

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

carry on then posted:

let me guess, this doesn't support any other calendaring systems because programmers are racists

Howard Hinnant (the author of the proposal) showed both the Chinese New Year calendar and lunar calendar as reasons for his design, and showed conversions between Gregorian and Julian calendars for astronomy.

This changed also standardized using tz databases.

oh and this code doesn’t work by default unless you put a using namespace in your code and that should give you a red flag to begin with unless you’re doing poo poo like ADL

Sweeper
Nov 29, 2007
The Joe Buck of Posting
Dinosaur Gum

Slurps Mad Rips posted:

oh and this code doesn’t work by default unless you put a using namespace in your code and that should give you a red flag to begin with unless you’re doing poo poo like ADL

this is the same for all of the timer literals, I never use them because of it

Falcorum
Oct 21, 2010

Sweeper posted:

this is the same for all of the timer literals, I never use them because of it

Or any of those literals really, I'm still curious as to what's the rationale for the string_view string literal.

Antigravitas
Dec 8, 2019

Die Rettung fuer die Landwirte:

Sapozhnik posted:

folks, ive been looking at c++ lately and lemme tell ya

it loving SUCKS!!!!!

Well, from now on you can use SQF for all your programming needs.

Money quote:

quote:

The SQF Language is fairly simple in how it is built. In fact: there are barely any actual language structures at all.

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

Falcorum posted:

Or any of those literals really, I'm still curious as to what's the rationale for the string_view string literal.

We can know the string length of a literal at compile time, so "asd"sv will calculate the length at compile time, while std::string_view x = "asd" may call strlen (it actually calls traits_type::length) at runtime, and when you're using a string literal there's not really a point in wasting a call to strlen. It's basically a micro-optimization :v:

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
when do you want to construct an instance of string_view?

pseudorandom name
May 6, 2007

I want my string_views constructed at compile time and stored in the read-only data segment

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

Slurps Mad Rips posted:

We can know the string length of a literal at compile time, so "asd"sv will calculate the length at compile time, while std::string_view x = "asd" may call strlen (it actually calls traits_type::length) at runtime, and when you're using a string literal there's not really a point in wasting a call to strlen. It's basically a micro-optimization :v:

i continue to be amazed that legendarily performance-focused c++ is essentially the only programming language on the planet where constructing a value of the standard string type from a string literal requires allocating memory and copying the string

animist
Aug 28, 2018

rjmccall posted:

i continue to be amazed that legendarily performance-focused c++ is essentially the only programming language on the planet where constructing a value of the standard string type from a string literal requires allocating memory and copying the string

c++ trusts the programmer (not to use any of the built-in APIs)

Xarn
Jun 26, 2015

rjmccall posted:

i continue to be amazed that legendarily performance-focused c++ is essentially the only programming language on the planet where constructing a value of the standard string type from a string literal requires allocating memory and copying the string

The cost of mutable and contiguous strings

And also of conflating the type of string literals with runtime string types.

Zlodo
Nov 25, 2006
aka the cost of backward compatibility with C, but without it C++ would probably never have taken off

Sweeper
Nov 29, 2007
The Joe Buck of Posting
Dinosaur Gum

Slurps Mad Rips posted:

We can know the string length of a literal at compile time, so "asd"sv will calculate the length at compile time, while std::string_view x = "asd" may call strlen (it actually calls traits_type::length) at runtime, and when you're using a string literal there's not really a point in wasting a call to strlen. It's basically a micro-optimization :v:

or just make the string view constexpr?, seems like that would be even easier and make your point clearer vs. the magical sv

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
you wouldn’t need to change the default type for literals, just allow types to opt in to a special rule when they’re being constructed by converting a literal expression

you could support mutation etc. by doing copy-on-write for those literal strings even if you didn’t do that for anything else

the committee just can’t actually get it together to do anything about it because it seems excessively targeted or something

Bloody
Mar 3, 2013

incredible how much of this is stuff that rust gets right

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

you can either be popular or right

DELETE CASCADE
Oct 25, 2017

i haven't washed my penis since i jerked it to a phtotograph of george w. bush in 2003
the right way to do dates and times is the way that postgres does it. except that a timestamptz should actually store the original tz and it doesn't, that is annoying. everything else though, perfect

Falcorum
Oct 21, 2010

carry on then posted:

you can either be popular or slower than c++ to compile

fixed

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

Bloody posted:

incredible how much of this is stuff that rust gets right

that's what i'm saying, literally every language except c++ gets this right, because they are designed by people with a non-hosed-up relationship to the language they work on

Bored Online
May 25, 2009

We don't need Rome telling us what to do.
what would be a bigger waste of my time long term. learning c++ real good or rust

DELETE CASCADE
Oct 25, 2017

i haven't washed my penis since i jerked it to a phtotograph of george w. bush in 2003
depends on what you consider wasted time. do you want to learn something, or do you want to stack paper? because you can learn rust, but there are not a ton of rust jobs. on the other hand, plenty of work in c++, but you are not going to learn c++ real good. no mere mortal is capable of that. the best you can hope for is to learn a particular dialect of c++ real good, and which dialect you must learn generally depends on the type of work you want to do, and the people you are doing it with

taqueso
Mar 8, 2004


:911:
:wookie: :thermidor: :wookie:
:dehumanize:

:pirate::hf::tinfoil:

do both and find out!

b0lt
Apr 29, 2005

Bloody posted:

incredible how much of this is stuff that rust gets right

rust gets this even more wrong than C++, passing a string literal into anything that takes an owning String forces you to explicitly convert it from &str to String, so you have noise like map.insert("foo".to_string(), "bar".to_string()) *everywhere*

mystes
May 31, 2006

b0lt posted:

rust gets this even more wrong than C++, passing a string literal into anything that takes an owning String forces you to explicitly convert it from &str to String, so you have noise like map.insert("foo".to_string(), "bar".to_string()) *everywhere*
In rust it probably comes at zero cost except to your sanity (that should actually be their slogan).

Lime
Jul 20, 2004

i thought rust's owning String always puts it on the heap and "string literal".to_string() definitely allocates

mystes
May 31, 2006

Lime posted:

i thought rust's owning String always puts it on the heap and "string literal".to_string() definitely allocates
Actually yeah that's probably one of the reasons they make you do it explicitly.

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

b0lt posted:

rust gets this even more wrong than C++, passing a string literal into anything that takes an owning String forces you to explicitly convert it from &str to String, so you have noise like map.insert("foo".to_string(), "bar".to_string()) *everywhere*

its not that bad. the compiler tells you when you need to perform the correct incantations

Bloody
Mar 3, 2013

b0lt posted:

rust gets this even more wrong than C++, passing a string literal into anything that takes an owning String forces you to explicitly convert it from &str to String, so you have noise like map.insert("foo".to_string(), "bar".to_string()) *everywhere*

yes, and this is a good thing

taqueso
Mar 8, 2004


:911:
:wookie: :thermidor: :wookie:
:dehumanize:

:pirate::hf::tinfoil:

You can write your function so it accepts anything that can be turned into a string using a trait, no?

Slurps Mad Rips
Jan 25, 2009

Bwaltow!

Sweeper posted:

or just make the string view constexpr?, seems like that would be even easier and make your point clearer vs. the magical sv

constexpr means that it can run at compile time but it doesn’t guarantee that it will. There are some cases where it simply can’t, such as parameters to a non-constexpr function.

consteval, added in C++20 is a “compile time only” form, and constexpr now forms the bridge.

also to be fair we added operator “”sv so we have parity with the std::string form.

honestly the suffix stuff is rarely used overall, (except for maybe complex floats?), but then again a lot of them are like that. it might change once my paper for allowing 69i64 makes it in. it’s just easier to write 69i64 than the “proper” way of INT64_C(69).

I’m making C++ like rust, one terrifying operator overload at a time. :v:

also once upon a time we were going to permit literal types like string view in template parameters but NOT permit char const* literals. hence the “”sv operator. this ended up not panning our and we just ended up allowing char const* literals in template parameters. but now we can’t remove the dumb stuff because “wHaT aBoUt mY AbI?!”

Vanadium
Jan 8, 2005

taqueso posted:

You can write your function so it accepts anything that can be turned into a string using a trait, no?

Yes but that sucks to write and read a lot more than just saying `string` like a normal language.

redleader
Aug 18, 2005

Engage according to operational parameters
c++ may simply be too beautiful for this dirty, tarnished world

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

it’s not

Zlodo
Nov 25, 2006

fart simpson posted:

its not that bad. the compiler tells you when you need to perform the correct incantations

you shouldn't need to perform any incantation to pass a string literal to a function as a read only string

c++ gets it wrong: "c++ bad"
rust gets it wrong: "rust good"

dick traceroute
Feb 24, 2010

Open the pod bay doors, Hal.
Grimey Drawer
c++ can't get it wrong all of the time because it does everything every possible way
one of them must be right right

ynohtna
Feb 16, 2007

backwoods compatible
Illegal Hen
c++ has a print-out of a scheme implementation in its attic

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

Zlodo posted:

c++ gets it wrong: "c++ bad"
rust gets it wrong: "rust good"

this but unironically

Adbot
ADBOT LOVES YOU

Cybernetic Vermin
Apr 18, 2005

there being such a thing as a "string-like" reminds me why i prefer to just not do modern low-level programming, or the really dumb kind of high-level programming which would have a string-like.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply