Arc Forumnew | comments | leaders | submitlogin
3 points by cchooper 5965 days ago | link | parent

My suggestion: when regexps are used in the functional place, they should do what users most likely want from them.

  arc> (s/b(\w)/d\\1/g "bobcat")
  "dodcat"
but they can also be used as arguments to functions, which will give you all the other behaviour.

  arc> (match s/b(\w)/d\\1/g "bobcat")
  ("b" "o" "b" "c" "a" "t")

  arc> (sub s/b(\w)/d\\1/g "bobcat")
  "dodcat"

  arc> (match-and-sub s/b(\w)/d\\1/g "bobcat")
  ("dodcat" ("b" "o" "b" "c" "a" "t"))
or something like that. My regexp knowledge is a little rusty. I also agree with stefano's point that they should be part of the standard library. This would be possible if there were easy ways to reprogram the Arc syntax in a library.


3 points by almkglor 5965 days ago | link

> This would be possible if there were easy ways to reprogram the Arc syntax in a library.

Again, like I said, this is probably implementable using readermacros, but fooling around with the reader is always troublesome.

Consider some random programmer who uses /ca/ as a variable name in his or her programs for some inexplicable reason. Whether this is considered a regular expression or a valid symbol will then depend on whether or not it is loaded before or after the regular expression library.

If you want nice regular expression syntax, then it must be standardized as part of the language syntax so that everyone knows they should avoid using such variable names. Alternatively, give some method for specifying a reader for each module file. No, this is an exploratory language, and someone will try using /ca/ as a variable name unless you specifically ban it. I promise you that.

This is only partially implementable using ssyntax, but again this may be considered as "fooling around with the reader".

If strings as regular expressions work for you, then it's okay, since strings are already standardized in the syntax:

  arc> ((rex "s/b(\\w)/d\\\\1/g") "bobcat")
  "dodcat"

-----

4 points by cchooper 5965 days ago | link

Strings would work ok if Arc had a means of representing unprocessed strings like Perl or C#.

  arc> ((rex @"s/b(\w)/d\\1/g") "bobcat")
Has lots of other uses too, so I think this would be a good feature regardless.

-----

1 point by almkglor 5964 days ago | link

True, another good place would be docstrings.

Now all we need is to (re)build a reader for Arc. ^^

-----