3 ms·
Now I'm interested to know which languages exist that don't rely heavily on backslashes. I guess I can't think of a language that doesn't use blackslashes for
by GregBuchholz 14y ago
Now I'm interested to know which languages exist that don't rely heavily on backslashes. I guess I can't think of a language that doesn't use blackslashes for string escapes. Some other uses off the top of my head:
* C -- line-continuations (important for macros).
* Perl -- regex back-references.
* Haskell -- anonymous functions.
* Python -- line continuation.
* Tcl -- line continuation.
* Icon -- non-null test (unary), generator limitation (binary).
* Prolog -- \+ for not provable.
* J -- the prefix adverb and the grade-down verb (\:).
* TeX -- Yes.
- rfurmani 14y agoTechnically, for Perl you can use $ for regex backreferences. I don't remember which one is preferred, but I remember it frowning upon one of them.
- btilly 14y agoWhat you use depends on where you use it. Inside of a match, \1 refers to what was matched by the first parens. After the match $1 refers to what was matched. In a substitution, \1 is special cased to mean $1, but that is frowned on. Thus: /\b(\w+)\W+\1\b/ means "match repeated word". And: /\b(\w+)\W+$1\b/ means "match word preceeded by the word matched on your last match. Moving on: s/Hello (\w+)/Goodbye $!/ means "Replace Hello followed by a word with Goodbye followed by the same word." And finally: s/Hello (\w+)/Goodbye \1/ is special cased to mean the same thing, but is frowned upon.
- rdtsc 14y ago> Now I'm interested to know which languages exist that don't rely heavily on backslashes. I posit that line continuations don't count, at least not in the "rely heavily" category. Then I am not sure how popular J and Icon are. So let' keep those away. Is the backlash really used that often in Prolog? I wouldn't say "heavily". So that leaves us with: * Perl * Haskell * Tex I think that's a more realistic "rely heavily" category.
- GregBuchholz 14y ago"\tDon't forget the \"main\" uses.\u263A\n"
- runn1ng 14y agoDuring my perl experience, I learned that any special character next to $ is usually some magic variable that does something. So I would bet that $\ also does something. edit: oh yeah. $\ - The output record separator for the print operator. If defined, this value is printed after the last of print's arguments. Default is undef.