Re: C# programmer wants to learn assembly?? plz help
- From: David Jones <ncic@xxxxxxxxxx>
- Date: Sat, 30 Dec 2006 11:16:35 -0600
Dragontamer <prtiglao@xxxxxxxxx> wrote...
David Jones wrote:
<//\\\\o//\\\\annabee <"WINOS IS ***.">> wrote...
På Sat, 30 Dec 2006 03:56:29 +0100, skrev David Jones <ncic@xxxxxxxxxx>:
Here's a counter-example: let's say you need to verify that an email
address in a string has the format something@xxxxxxxxxxx? (string +
'@' + string + '.' + string, with only one @ in the string) See how
long it takes you to write it in assembly.
Then compare to ECMAScript: /^[^\s\@]+\@[^\s\@]+\.[^\s\@]+$/.test(str)
Guess which one would take longer for me to write.... (hint: if I wrote
the code above while I was typing my reply, the ECMAScript version
didn't take too long -- show me the equivalent with RosAsm, please)
I am uberdrunk, but lets give it a try:
call IsEmailAddress
That's really disingenuous, you know. First of all, I have no
documentation for this library function, so I can't tell if it *EXACTLY*
meets the specification I listed. Second, who says an HLL can't have a
library function that does the same thing?
You completely missed the point. Write the validation in assembly just
using the base language. *YOU'RE* the one who stated writing from
scratch is easier in assembly, yet when it comes time to actually do it,
you don't want to. If it's so much easier, and it makes you so much
more productive, prove it.
Look at the phone number validation in my reply to ¬a\/b and give me the
RosAsm version:
Accept any of:
(202) 555-1212
(202)555-1212
202/555-1212
202.555.1212
2025551212
HLL version:
if (/^(\(\d{3}\)\s?)?\d{3}[\-\.]\d{4}$/.test(str) ||
/^\d{3}([\-\.])\d{3}\1\d{4}$/.test(str) ||
/^\d{3}\/\d{3}[\-\.]?\d{4}$/.test(str) ||
/^\d{3}?\d{7}$/.test(str))
{
// ... valid ...
}
else
{
// ... invalid ...
}
ECMAscript?? Ewww... Go Perl :-)
Yeah, Perl would be a better example, but IIRC the regex syntax is
different, and I only know ECMAScript regex syntax.
if(string =~ m/\(?\d{3}\)?\s*\d{3}(-|.)?\d{4}/ )
There, and no nasty || statements making the example
excessivly long.
The reason for the || is to break it up so that you don't have lots of |
in the expression. Your version wouldn't work since it would also
match:
(202 555.1212
And doesn't match:
202/555-1212
Took about 1 minute but no test yet; cause I suck with Perl
and don't feel like compile-checking :-p
Does ECMAscript have grouping? In Perl you can just
do \d{3}(-|.)?\d{3} and that will match each of the following:
Yes, I used it in the other example.... :)
David
.
- Follow-Ups:
- Re: C# programmer wants to learn assembly?? plz help
- From: Dragontamer
- Re: C# programmer wants to learn assembly?? plz help
- References:
- C# programmer wants to learn assembly?? plz help
- From: giddy
- Re: C# programmer wants to learn assembly?? plz help
- From: Frank Kotler
- Re: C# programmer wants to learn assembly?? plz help
- From: //\\\\o//\\\\annabee
- Re: C# programmer wants to learn assembly?? plz help
- From: Herbert Kleebauer
- Re: C# programmer wants to learn assembly?? plz help
- From: Betov
- Re: C# programmer wants to learn assembly?? plz help
- From: Herbert Kleebauer
- Re: C# programmer wants to learn assembly?? plz help
- From: Betov
- Re: C# programmer wants to learn assembly?? plz help
- From: Herbert Kleebauer
- Re: C# programmer wants to learn assembly?? plz help
- From: David Jones
- Re: C# programmer wants to learn assembly?? plz help
- From: David Jones
- Re: C# programmer wants to learn assembly?? plz help
- From: David Jones
- Re: C# programmer wants to learn assembly?? plz help
- From: Dragontamer
- C# programmer wants to learn assembly?? plz help
- Prev by Date: Re: C# programmer wants to learn assembly?? plz help
- Next by Date: Re: C# programmer wants to learn assembly?? plz help
- Previous by thread: Re: C# programmer wants to learn assembly?? plz help
- Next by thread: Re: C# programmer wants to learn assembly?? plz help
- Index(es):