Builtin regex (Was: How to complex switch?)

Robert Clipsham robert at octarineparrot.com
Sat May 14 11:59:48 PDT 2011


On 13/05/2011 17:52, Dmitry Olshansky wrote:
>> When you've written a couple it doesn't take much to get it right in
>> my experience. I don't find them hard to maintain personally, I guess
>> that comes from experience though. What do you mean port?
>
> Literally code the same in another programming language. Suppose there
> are going to be other programs working with the same data in similar ways.

extern(C) - you can now access it with C/C++, and D has bindings for a 
good few scripting languages! Why rewrite your code in another language 
at all? :D

>> As for patching for new input, that's a doddle if it's well written.
>> Changing a regex on the other hand... It's generally easier to write
>> it from scratch than decipher a current one.
>>
> I see, the deciphering could really get tricky. As for rewriting from
> scratch that's something you generally try hard to avoid with
> handwritten stuff.

You generally don't need to rewrite it when it's hand written, just 
tweak it.

>> Of course, I don't feel that grants them a place in the language
>> though. Particularly with the likes of octal! - it can quite easily be
>> in a library and work just as well.
>
> Sure thing it shouldn't be built it. D isn't awk.

Glad we agree!

>> I have, and I use regex for it. Those kinda things just need a quick
>> hack, and that's how I treat regex. If I'm doing anything that's
>> getting used in production code/anything that isn't intended to be a
>> hack I write a proper parser.
>
> Ok, so I think we can agree on the simple fact that there are things
> that just do not worth handwritten parser.

Of course.

-- 
Robert
http://octarineparrot.com/


More information about the Digitalmars-d mailing list