Legacy of Anders Hejlsberg! The EmptyChar!
-
This code doesn't compile.
var guid = Guid.NewGuid().ToString().Replace('-', '');
This code does compile.
var guid = Guid.NewGuid().ToString().Replace("-", "");
DO NOT BE AFRAID TO TRY THIS ON YOUR FAVORITE C# COMPILER.
-
@Nagesh that's because the first line doesn't make sense, the second one does.
-
@topspin said in Legacy of Anders Hejlsberg! The EmptyChar!:
@Nagesh that's because the first line doesn't make sense, the second one does.
C# didn't do that wrong? Weird.
-
@topspin I believe both lines SHOULD MAKE SENSE!
You will agree after Jon Skeet or Anders make this statement.
-
@Nagesh If C# invented an empty char, just to make you feel better, they would throw away the ability to optimize char replacement. As is, the library could do replacement using a simple loop. Replacing one of the real char arguments with an empty char would require the implementation track the position in both the original string and the result independently.
There are a bunch of other documented features of the char type that would also be weird if an empty char existed, like the ability to convert between char and the numeric types.
-
@Nagesh said in Legacy of Anders Hejlsberg! The EmptyChar!:
@topspin I believe both lines SHOULD MAKE SENSE!
You will agree after Jon Skeet or Anders make this statement.
Definitely not.
A string is a sequence of characters. An empty sequence is obviously a sequence. An "empty character" is not a character.
Take the following:
int[] a = {1, 2, 3}; // array of 3 integers int[] b = {}; // array of 0 integers
Makes perfect sense. Now, instead of sequences, look at the individual things:
int c = 1; // single integer int d = {} // Um, what?!
An "empty integer" doesn't make sense. Unless maybe you want to make it nullable, but that's a different concept.
-
@Nagesh said in Legacy of Anders Hejlsberg! The EmptyChar!:
DO NOT BE AFRAID TO TRY THIS ON YOUR FAVORITE C# COMPILER.
But not your favorite C# composer
-
@slapout1 said in Legacy of Anders Hejlsberg! The EmptyChar!:
your favorite C# composer
-
@Nagesh If the code in question is not just EmptyChar example, you could do
var guid = Guid.NewGuid().ToString("N");
to avoid the bother altogether.
-
@Nagesh said in Legacy of Anders Hejlsberg! The EmptyChar!:
@topspin I believe both lines SHOULD MAKE SENSE!
You will agree after Jon Skeet or Anders make this statement.
They do, but one doesn't compile.
-
@slapout1 said in Legacy of Anders Hejlsberg! The EmptyChar!:
@Nagesh said in Legacy of Anders Hejlsberg! The EmptyChar!:
DO NOT BE AFRAID TO TRY THIS ON YOUR FAVORITE C# COMPILER.
But not your favorite C# composer
๐ฌ๐๐๐๐๐ ๐๐๐๐ ๐๐๐๐๐๐๐๐๐๐ ๐๐ ๐๐๐๐๐๐ ๐๐๐๐๐๐ ๐๐๐๐๐ ๐๐๐๐๐๐๐๐ ๐๐๐๐๐. ๐ฎ๐๐ - ๐ญ๐๐๐๐๐๐๐๐.
-
@Nagesh said in Legacy of Anders Hejlsberg! The EmptyChar!:
@slapout1 said in Legacy of Anders Hejlsberg! The EmptyChar!:
@Nagesh said in Legacy of Anders Hejlsberg! The EmptyChar!:
DO NOT BE AFRAID TO TRY THIS ON YOUR FAVORITE C# COMPILER.
But not your favorite C# composer
๐ฌ๐๐๐๐๐ ๐๐๐๐ ๐๐๐๐๐๐๐๐๐๐ ๐๐ ๐๐๐๐๐๐ ๐๐๐๐๐๐ ๐๐๐๐๐ ๐๐๐๐๐๐๐๐ ๐๐๐๐๐. ๐ฎ๐๐ - ๐ญ๐๐๐๐๐๐๐๐.
๐น๐๐จ๐๐ฃ๐ ๐ฅ๐๐ ๐๐๐ค๐ฆ๐ค๐ ๐ ๐ ๐๐๐ฅ๐๐๐๐๐ฅ๐๐๐๐ ๐๐ช๐๐๐ ๐๐คโฆ
-
The empty char should be null.
-
@boomzilla wouldn't that just make
''
an abbreviation for'\u0000'
?
-
@Watson you mean
'\0'
?
-
@Gฤ ska
$'{null}'
?
-
In any case, not โ.
My only regret is that I can't see if anyone posted an actual NUL character unless I . Would NodeBB even allow it to go through?
-
@Zecc I'll let you know as soon as I figure out how to even write it.
-
Slightly related: trying to figure out why my diff tool reports certain lines in a translation file as Modified, yet no changes within the line are highlighted.
Turns out some translator has been inserting zero-width spaces in text which doesn't need it, and highlighting an invisible character obviously isn't going to help much to find it.
-
@Gฤ ska said in Legacy of Anders Hejlsberg! The EmptyChar!:
@Zecc I'll let you know as soon as I figure out how to even write it.
Cut-n-paste it from elsewhere?
(Most systems really can't handle it in text at all as it is used as a terminator, a legacy of C. Handling NUL smoothly without horrible consequences elsewhere is really quite a bit harder than it looks as there's a great many pitfalls.)
-
@JBert said in Legacy of Anders Hejlsberg! The EmptyChar!:
Turns out some translator has been inserting zero-width spaces in text which doesn't need it
-
@dkf said in Legacy of Anders Hejlsberg! The EmptyChar!:
@Gฤ ska said in Legacy of Anders Hejlsberg! The EmptyChar!:
@Zecc I'll let you know as soon as I figure out how to even write it.
Cut-n-paste it from elsewhere?
No . As I was considering whether to , I did think of what it would take to programatically copy a NUL to clipboard. Sounds like less work than making a programatic post.
In fact, screw it. Apparently this is enough:
// PresentationCore.dll System.Windows.Clipboard.SetData(System.Windows.DataFormats.Text, "\u0000");
Here it is:
...I think.
-
Booo!
-
This post is deleted!
-
@Zecc said in Legacy of Anders Hejlsberg! The EmptyChar!:
Booo!
But you did enter it. You just can't render it. It's below 31.
-
This post is deleted!