mIRC Home    About    Download    Register    News    Help

Topic Options
#19090 - 14/04/03 01:32 AM | | should not cause a problem, but does
NaquadaServ Offline
Fjord artisan

Registered: 12/12/02
Posts: 580
If this isn't a problem...
Code:
test { echo -a TEST | $null | echo -a Test }

Why is this a problem?
Code:
test { echo -a TEST |  | echo -a Test }

I get an unknown command |, from the server with the second bit of code.
_________________________
NaquadaBomb
www.mirc-dll.com

Top
#19091 - 14/04/03 10:18 AM Re: | | should not cause a problem, but does
starbucks_mafia Offline
Hoopy frood

Registered: 09/12/02
Posts: 2962
Loc: Norwich, UK
There's no reason why it shouldn't give an error, it's bad syntax. If anything the strangeness would be that using $null there doesn't return an error.
_________________________
Spelling mistakes, grammatical errors, and stupid comments are intentional.

Top
#19092 - 14/04/03 05:35 PM Re: | | should not cause a problem, but does
tomalak16 Offline
Vogon poet

Registered: 24/12/02
Posts: 109
Loc: UK
It's all to do with evaluation order.

In the first example, the script engine thingie comes across the $null, and its first 'thought' is that this is something to execute. it's second thought is that this something is a null value, and so does nothing. but at the top-most level, there is something there: the plain-text "$null". (Note this is why extra evaluation in scripting normally requires TWO sets of eval brackets)

In the second example, the engine's first thought is that '|' is something to execute. With this logic, '| echo -a test' is the line to execute, which is why you get the server error, because there is no '|' command, with or without the extra text. If there was more text before the pipe character, it would assume THAT to be a command on its first thought.
| is, just lke $null, a second-evaluation device. | and $null are plain text, but when evaluated (if given the chance), they become a newline, and empty space.

I realise this is a very confusing post. But I believe at least some of it makes sense smile

Note: the idea of 'thought' here is synonymous with that of evaluation. I just like the word better.
_________________________
<Ingo> I can't uninstall it, there seems to be some kind of "Uninstall Shield"

Top
#19093 - 15/04/03 01:56 PM Re: | | should not cause a problem, but does
vague Offline
Ameglian cow

Registered: 18/12/02
Posts: 39
Loc: Sweden
The mIRC Script parser is highly irregular and fragile. It's ad hoc and it's interpretation can often be hard to predict. Inconsistencies like that one are regular occurences.

This is a pitty, partly because parser construction is a very well researched branch of computer science, i.e. there are very well known and regular techniques for making parsers, it's not much of a craft and very much engineering. And it's easy, dead simple, once you know a good tool (and many good tools are available for free).

Top
#19094 - 15/04/03 02:03 PM Re: | | should not cause a problem, but does
vague Offline
Ameglian cow

Registered: 18/12/02
Posts: 39
Loc: Sweden
(Ofcourse, since mIRC script has evolved with this parser, it's grammar is now sadly non context free and not very ammendable to standard parsing techniques. So, while it could probably be enhanced by using a real tool, such a tool can not fix the underlying difficulty that the language is ambigious. C and Perl suffers from similar problems, they are also hard to parse, although much (much) more regular than mIRC script.)

Top