Why do string macros in Julia use ...? -


I was looking for a r_str macro in julia, which parses r Regex ("text") in "text" . The second argument is flag ... , which flags pass in regex, such as insensitive to the i case, and so on.

I was playing it with myself and found:

  Julia & gt; Macro a_str (p, flags ...) print (flags) p & julia & gt; It seems that  iii  has been passed as the first flag, it seems that "ABC" iii ("iii", "abc"  

In that case, why is the code on the flag ... ? Is it possible to pass macro into more than one element of the flag ?

When this question was originally asked, a macro spreader - that is, defined with the macro keyword , Which is a macro in an output expression. Changed expressions are said to change - this was not normal function, but rather an anonymous function, which had a different type of function in Julia 0.4 and earlier versions. At that point, the only way to write an anonymous function signature is to Or could work for two arguments, to use a backward virus argument, that is why this pattern is used to define string macros. Or was. Julia have become all functions generic functions in 0.5, including anonymous functions and macro expander. Thus, now you can write a macro in a number of ways, including the old way of using a varargs argument after the strag argument:

  # old style macro rm_str (raw) , Rest ...) Remove = is empty (left)? "Aoi": replace the remaining [1] (raw, collect (remove), "") # replace the new style with two methods macro rm_str (raw) (raw, ['a', 'e' 'I', 'o', 'u', 'y'], "") end of the end macro rm_str (raw, deleted) (raw, collect (remove), "") end # The default second argument with macro rm_str (raw,  

All of these results are in the verbical behavior of the same non-standard string:

  Julia & gt; Rm "afu bar String Verbatim String has been stripped from the flagged letters, all of which are called ASCII. There is a mistake to take out vowels ("Ayeou"). The new approach to using the second argument with the default is the easiest and obvious in this case, because it will be in many cases, but now whatever approach Can best use. 


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -