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
comedyblissoption
Mar 15, 2006

the best part of stringly typed is when they shove an array into a string delimited by some character but don't consider if that delimiting character may be part of the content

(people who stringly type never consider this)

Adbot
ADBOT LOVES YOU

FlapYoJacks
Feb 12, 2009

comedyblissoption posted:

the best part of stringly typed is when they shove an array into a string delimited by some character but don't consider if that delimiting character may be part of the content

(people who stringly type never consider this)

I did this with a csv parser. :colbert:

csammis
Aug 26, 2003

Mental Institution
Just use non-printing ASCII characters for the delimiters, duh. No one's never going to type an ASCII ACK!

*starts accepting non-ASCII content*

:suicide:

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
why use ASCII ACK when there's the convenint ASCII record separator that nobody ever knows exists

xzzy
Mar 5, 2009

I wonder if this is what conversation was like at lunch the day csv was implemented.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

xzzy posted:

I wonder if this is what conversation was like at lunch the day csv was implemented.

Someone needs to make a series of one minute clips reenacting moments like that.

"And that protocol's name was... TCP"

Dr Monkeysee
Oct 11, 2002

just a fox like a hundred thousand others
Nap Ghost

Suspicious Dish posted:

why use ASCII ACK when there's the convenint ASCII record separator that nobody ever knows exists

I got a dump file from our data warehouse team the other day that used the ASCII unit separator between fields and was pleasantly surprised once I figured out what the undisplayable character was.

Stoatbringer
Sep 15, 2004

naw, you love it you little ho-bot :roboluv:

I've seen this sort of thing a lot recently, in dusty old layers of legacy code :

return a == b ? true : false;

Su-Su-Sudoko
Oct 25, 2007

what stands in the way becomes the way

Stoatbringer posted:

I've seen this sort of thing a lot recently, in dusty old layers of legacy code :

return a == b ? true : false;

... what language?
(though I guess it doesn't really matter)

taqueso
Mar 8, 2004


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

:pirate::hf::tinfoil:

Stoatbringer posted:

I've seen this sort of thing a lot recently, in dusty old layers of legacy code :

return a == b ? true : false;

I'm guessing C89 with poorly defined true & false.

1337JiveTurkey
Feb 17, 2005

Dr Monkeysee posted:

I got a dump file from our data warehouse team the other day that used the ASCII unit separator between fields and was pleasantly surprised once I figured out what the undisplayable character was.

Even better there are several layers above it so you've got record, group and file separators giving multiple levels. It's really weird that the original committee felt that these separators were worth 3% of the code space but everybody ends up developing a new way to express the same thing. And if for some reason you've got to handle data with those characters, there's the Data Link Escape character which is specifically for declaring that the next character should be passed through as raw data even if it is a control character.

edit: It'd be an amusing Goon Project to get those characters in wider use.

MrMoo
Sep 14, 2000

Reuters has used ASCII delimiters up until this decade and finally moved over to binary, primary competition was XDR which is a standard binary encoding for RPC.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Yeah, IPTC 7901 also uses those along with SOH/STX.

http://www.iptc.org/std/IPTC7901/1.0/specification/7901V5.pdf

Apex Rogers
Jun 12, 2006

disturbingly functional

hobbesmaster posted:

You assume it's a raw pointer and -> isn't overloaded as well. If it works though that moves the horror to whoever defined the behavior of those operators.

This is C, so no overloading. I don't think this piece of code has ever been executed, because the calling code, in the same file, checks for device validity ahead of the function call. Maybe some early testing caused a crash so the author added another check?

jony neuemonic
Nov 13, 2009

Stoatbringer posted:

I've seen this sort of thing a lot recently, in dusty old layers of legacy code :

return a == b ? true : false;

I still catch myself doing this once in a while. I've always caught it before code review, thankfully.

Fergus Mac Roich
Nov 5, 2008

Soiled Meat
TCL has a pattern that uses magic string arguments to imitate namespaces, ie string first, string cat, etc.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

jony neuemonic posted:

I still catch myself doing this once in a while. I've always caught it before code review, thankfully.

I'm fond of the rarer

bool x = (y == z) ? y : z;

which occurs occasionally in the code we took on when we acquired another company

Beef
Jul 26, 2004

xzzy posted:

I wonder if this is what conversation was like at lunch the day csv was implemented.

No audio, but I think this a picture of that very moment.




I should check, but the majority of the datasets we're dealing with are definitely not comma-separated. Part of it is because commas are the fraction symbol in our locale, the other is because cfr. screenshot.

Beef fucked around with this message at 16:51 on Oct 13, 2016

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Hammerite posted:

I'm fond of the rarer

bool x = (y == z) ? y : z;

which occurs occasionally in the code we took on when we acquired another company

This can be different from just returning one of y, z though.

seiken
Feb 7, 2005

hah ha ha
It's the same as just using z. Barring operator overloading shenanigans.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

leper khan posted:

This can be different from just returning one of y, z though.

I am aware that this is true in principle, yes, but you should not design your classes in that way so if you write that code you are definitely doing something wrong one way or another

Coffee Mugshot
Jun 26, 2010

by Lowtax
Uh how can that be different from just returning one or the other when x is a boolean which implies y and z are boolean? There's no way you're overloading the assignment operator on some class to sometimes return boolean when the object is secretly a struct.

Unless you're talking about some language where the ternary expression doesn't have precedence or something. But even in that case that would be the equivalent of if x = blah blah, do y, otherwise, do z. Which changes the entire argument.

Coffee Mugshot fucked around with this message at 13:51 on Oct 13, 2016

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Coffee Mugshot posted:

Uh how can that be different from just returning one or the other when x is a boolean which implies y and z are boolean? There's no way you're overloading the assignment operator on some class to sometimes return boolean when the object is secretly a struct.

Unless you're talking about some language where the ternary expression doesn't have precedence or something. But even in that case that would be the equivalent of if x = blah blah, do y, otherwise, do z. Which changes the entire argument.

Yeah, I made a mistake, just pretend I began the statement with "var" instead of "bool".

MisterZimbu
Mar 13, 2006
Vim Perils:

*Wants to undo some changes, hits 'u' to undo*

"Huh, why didn't it undo"

*Hit 'u' again, nothing happens*
*Hit 'u' several more times*

"Oh! I'm hitting '7', not 'u'! Silly me!"

*Actually hits 'u' this time, entire document reverts to what it was when i first opened Visual Studio*

xtal
Jan 9, 2011

by Fluffdaddy
Begrudgingly doing some Web programming and just found out the fastest) recommended way to clone an object in JavaScript is to turn it to json and back

brap
Aug 23, 2004

Grimey Drawer
All command line text editors are stupid and bad.

Space Kablooey
May 6, 2009


xtal posted:

Begrudgingly doing some Web programming and just found out the fastest) recommended way to clone an object in JavaScript is to turn it to json and back

Have you considered Object.assign()?

canis minor
May 4, 2011

xtal posted:

Begrudgingly doing some Web programming and just found out the fastest) recommended way to clone an object in JavaScript is to turn it to json and back

Probably :thejoke:, but there're caveats of this approach:

code:
{ data: new Date() }
>Object {data: Thu Oct 13 2016 16:29:01 GMT+0100 (GMT Daylight Time)}

JSON.parse(JSON.stringify({ data: new Date() }));
>Object {data: "2016-10-13T15:29:16.932Z"}

JSON.parse(JSON.stringify({ foo: function(){} }));
>Object {}

xtal
Jan 9, 2011

by Fluffdaddy

It's only a shallow clone and I'm unsure of its compatibility

Space Kablooey
May 6, 2009


xtal posted:

It's only a shallow clone and I'm unsure of its compatibility

Compatibility isn't really a problem, except for IE 11, but for deep copies then welp.

taint toucher
Sep 23, 2004


Suspicious Dish posted:

why use ASCII ACK when there's the convenint ASCII record separator that nobody ever knows exists

There's even two so you can implement stringly-typed mappings! :doh:

Klades
Sep 8, 2011

fleshweasel posted:

All command line text editors are stupid and bad.

You can have vim keybindings without using a command line editor.

LOOK I AM A TURTLE
May 22, 2003

"I'm actually a tortoise."
Grimey Drawer

xtal posted:

Begrudgingly doing some Web programming and just found out the fastest) recommended way to clone an object in JavaScript is to turn it to json and back

How do you deal with circular references?

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

LOOK I AM A TURTLE posted:

How do you deal with circular references?

Whimper softly.

Klades
Sep 8, 2011

LOOK I AM A TURTLE posted:

How do you deal with circular references?

Burn the code, pillage the spec, replace everything with a pong clone that bounces the balls at the wrong angle.

hobbesmaster
Jan 28, 2008

Klades posted:

You can have vim keybindings without using a command line editor.

Which raises the question: Why?

Soricidus
Oct 21, 2010
freedom-hating statist shill

hobbesmaster posted:

Which raises the question: Why?

some people are sadly exposed to vim key bindings at an impressionable age, and the resultant brain damage cripples their ability to learn and work with proper emacs keybindings

Doc Hawkins
Jun 15, 2010

Dashing? But I'm not even moving!


I'd rather damage my brains than my fingers: this thread has proven many times over you only need the latter to have a successful career in software.

Klades
Sep 8, 2011

Soricidus posted:

some people are sadly exposed to vim key bindings at an impressionable age, and the resultant brain damage cripples their ability to learn and work with proper emacs keybindings

Modeless heathen!

hobbesmaster posted:

Which raises the question: Why?

Some people prefer the tools provided by vim, even if they're using an interface that allows a mouse. If I need to delete a line, I just press "dd" and it's gone. Erase a word? Navigate to it, cw, type, esc. There's a definite learning curve, so it's understandable if a person doesn't care to learn it, but I like it.

Adbot
ADBOT LOVES YOU

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

hobbesmaster posted:

Which raises the question: Why?

It seems pretty inconsequential, but I find the reaching for the mouse and clicking around to things I'm trying to find can interrupt my train of thought. With a decent IDE/editor and vim bindings, I can navigate through an entire codebase without taking my fingers off the keyboard. A few years back I put some effort into being more proficient with vim and learning all the navigation keyboard commands built into Visual Studio, and once that became automatic I felt much more productive. However, this has the side effect of making me significantly less productive on someone else's machine without vim bindings or with a different keyboard shortcut setup.

I also have the honor of being the fastest code editor in the office, which has vastly improved my love life.

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