2 ms·
>How would it allow you to write a regex that matches a dot? You could write 1:. >Or text in an XML element that includes an ampersand? The point is to
by benibela 7y ago
>How would it allow you to write a regex that matches a dot?
You could write
1:.
>Or text in an XML element that includes an ampersand?
The point is to not use XML, because it has escape characters. You could replace it with ASN.1 BER
>Even for quotes contained in string literals it's a shitty solution because string literals are part of programming languages and having to count characters every time you change a String literal is just about the last thing you want in your language (and it would be horrible to read as well).
The IDE could update the length automatically
- brazzy 7y ago> You could write 1:. So separate wildcards and literals, each prepended by length? That would be far, far less readable than using escape sequences. > The point is to not use XML, because it has escape characters. You could replace it with ASN.1 BER Fair enough, but most people would consider that a solution worse than the problem. > The IDE could update the length automatically Making you completely dependent on an IDE to support whatever format you're editing, including nesting. You can't even read your code now without an IDE. Making up some kind of DSL on the fly? Start counting string lengths again. Sorry, but no. Escape sequences are bad, this would so much worse.
- benibela 7y ago>So separate wildcards and literals, each prepended by length? That would be far, far less readable than using escape sequences. Wildcards do not need a prefix, when they always are a single character. Here is a ordinary regex for a path: C:\\foo\\bar\\.*\.txt And here the regex in C: "C:\\\\foo\\\\bar\\\\.*\\.txt" But with lengths in a hypothetical syntax: 11:C:\foo\bar\.*4:.txt 22:11:C:\foo\bar\.*4:.txt That is quite readable > You can't even read your code now without an IDE. Making up some kind of DSL on the fly? Start counting string lengths again. I like binary formats. The lengths are easy to see in a hex editor. 16 bytes in each line or something You always depend on an IDE to decode the file. You could not read an UTF-8 file, if it would not decode the UTF-8 characters and show individual bytes. Or read ASCII if it were showing individual bits.