1. Wildcard_match behaviour

Why is this sentence not detected as an error? [missing ")" in first
wildcard_match is at the end]

if...
		
elsif wildcard_match("--month=???", cmd[3] and
wildcard_match("--update=NET-???", cmd[4])) then

else...

end if }}}



Thanks,

JG }}}

new topic     » topic index » view message » categorize

2. Re: Wildcard_match behaviour

Julio C. Galaret Viera wrote:
> 
> Why is this sentence not detected as an error? [missing ")" in first
> wildcard_match
> is at the end]
> 
> }}}
<eucode>
> if...
> 		
> elsif wildcard_match("--month=???", cmd[3] and
> wildcard_match("--update=NET-???", cmd[4]))
> then
> 
> else...
> 
> end if
> }}}
<eucode>

It's not an error technically.

What you're doing is and-ing `wildcard_match("--update=NET-???", cmd[4])` and
`cmd[3]` and then calling `wildcard_match("--month=???",` with the result.

new topic     » goto parent     » topic index » view message » categorize

3. Re: Wildcard_match behaviour

D. Newhall wrote:
> 
> Julio C. Galaret Viera wrote:
> > 
> > Why is this sentence not detected as an error? [missing ")" in first
> > wildcard_match
> > is at the end]
> > 
> > }}}
<eucode>
> > if...
> > 		
> > elsif wildcard_match("--month=???", cmd[3] and
> > wildcard_match("--update=NET-???", cmd[4]))
> > then
> > 
> > else...
> > 
> > end if
> > }}}
<eucode>
> 
> It's not an error technically.
> 
> What you're doing is and-ing `wildcard_match("--update=NET-???", cmd[4])` and
> `cmd[3]` and then calling `wildcard_match("--month=???",`
> with the result.

I see but... how can I technically *and* a string and a boolean result and then
compare altogether with another string? Too confusing for me.
Too much flexibility for my taste since I've been spending so much time trying
to figure out why the program wasn't doing what it should and without giving any
error message.

JG

new topic     » goto parent     » topic index » view message » categorize

4. Re: Wildcard_match behaviour

Julio C. Galaret Viera wrote:
> 
> D. Newhall wrote:
> > 
> > Julio C. Galaret Viera wrote:
> > > 
> > > Why is this sentence not detected as an error? [missing ")" in first
> > > wildcard_match
> > > is at the end]
> > > 
> > > }}}
<eucode>
> > > if...
> > > 		
> > > elsif wildcard_match("--month=???", cmd[3] and
> > > wildcard_match("--update=NET-???", cmd[4]))
> > > then
> > > 
> > > else...
> > > 
> > > end if
> > > }}}
<eucode>
> > 
> > It's not an error technically.
> > 
> > What you're doing is and-ing `wildcard_match("--update=NET-???", cmd[4])`
> > and `cmd[3]` and then calling `wildcard_match("--month=???",`
> > with the result.
> 
> I see but... how can I technically *and* a string and a boolean result and
> then compare altogether
> with another string? Too confusing for me.
> Too much flexibility for my taste since I've been spending
> so much time trying to figure out why the program wasn't doing what it should
> and without giving
> any error message.
> 
> JG

In order to technically *and* and  *compare* string and booland(unlike values)),
you must change them like values, ether both sequence or booland.


Don Cole
 Bonds > Ruth.
 Giants STILL in last place 
 Hmmmmmmmm!

new topic     » goto parent     » topic index » view message » categorize

5. Re: Wildcard_match behaviour

Julio C. Galaret Viera wrote:

> D. Newhall wrote:
>
>> Julio C. Galaret Viera wrote:
>>>
>>> Why is this sentence not detected as an error? [missing ")" in first
>>> wildcard_match
>>> is at the end]
>>>
>>> }}}
<eucode>
>>> if...
>>>
>>> elsif wildcard_match("--month=???", cmd[3] and
>>> wildcard_match("--update=NET-???", cmd[4]))
>>> then
>>>
>>> else...
>>>
>>> end if
>>> }}}
<eucode>
>>
>> It's not an error technically.
>>
>> What you're doing is and-ing `wildcard_match("--update=NET-???", cmd[4])` and
>> `cmd[3]` and then calling `wildcard_match("--month=???",`
>> with the result.
> 
> I see but... how can I technically *and* a string and a boolean result and
> then compare altogether
> with another string? Too confusing for me.

I've rewritten the code so that we can see a little better what's going on:

include wildcard.e

constant cmd = {"euphoria", "prog.ex", "--month=jan", "--update=NET-xyz"}

sequence s
integer r, t

r = wildcard_match("--update=NET-???", cmd[4])
s = cmd[3] and r
t = wildcard_match("--month=???", s)

? r
? s
? t


Euphoria neither has a built-in 'string' type nor a 'boolean' type.
Technically the line 
     s = cmd[3] and r
is 'and'-ing a sequence and an integer. The rules for operations on
sequences apply <http://rapideuphoria.com/refman_2.htm#26>.

( And then the line
     t = wildcard_match("--month=???", s)
  calls wildcard_match() with 2 sequences, which is quite normal. )

> Too much flexibility for my taste since I've been spending so much time
> trying to figure out why the program wasn't doing what it should and
> without giving any error message.

Maybe this actually is the price of Euphoria's flexibility?
I don't know.

Regards,
   Juergen

-- 
Please excuse my flawed English. My native language is Euphoria.

new topic     » goto parent     » topic index » view message » categorize

6. Re: Wildcard_match behaviour

Juergen Luethje wrote:
> 
> Julio C. Galaret Viera wrote:
> 
> > D. Newhall wrote:
> >
> >> Julio C. Galaret Viera wrote:
> >>>
> >>> Why is this sentence not detected as an error? [missing ")" in first
> >>> wildcard_match
> >>> is at the end]
> >>>
> >>> }}}
<eucode>
> >>> if...
> >>>
> >>> elsif wildcard_match("--month=???", cmd[3] and
> >>> wildcard_match("--update=NET-???", cmd[4]))
> >>> then
> >>>
> >>> else...
> >>>
> >>> end if
> >>> }}}
<eucode>
> >>
> >> It's not an error technically.
> >>
> >> What you're doing is and-ing `wildcard_match("--update=NET-???", cmd[4])`
> >> and `cmd[3]` and then calling `wildcard_match("--month=???",`
> >> with the result.
> > 
> > I see but... how can I technically *and* a string and a boolean result and
> > then compare altogether
> > with another string? Too confusing for me.
> 
> I've rewritten the code so that we can see a little better what's going on:
> 
> }}}
<eucode>
> include wildcard.e
> 
> constant cmd = {"euphoria", "prog.ex", "--month=jan", "--update=NET-xyz"}
> 
> sequence s
> integer r, t
> 
> r = wildcard_match("--update=NET-???", cmd[4])
> s = cmd[3] and r
> t = wildcard_match("--month=???", s)
> 
> ? r
> ? s
> ? t
> </eucode>
{{{

> 
> Euphoria neither has a built-in 'string' type nor a 'boolean' type.
> Technically the line 
>      s = cmd[3] and r
> is 'and'-ing a sequence and an integer. The rules for operations on
> sequences apply <<a
> href="http://rapideuphoria.com/refman_2.htm#26">http://rapideuphoria.com/refman_2.htm#26</a>>.
> 
> ( And then the line
>      t = wildcard_match("--month=???", s)
>   calls wildcard_match() with 2 sequences, which is quite normal. )
> 
> > Too much flexibility for my taste since I've been spending so much time
> > trying to figure out why the program wasn't doing what it should and
> > without giving any error message.
> 
> Maybe this actually is the price of Euphoria's flexibility?
> I don't know.
> 
> Regards,
>    Juergen
> 
> -- 
> Please excuse my flawed English. My native language is Euphoria.

I know in Euphoria doesn't exist a boolean type; it's just an integer.
The case is that I didn't want to *and* a sequence with an integer.
I simply made a mistake forgeting to close a ")". I only wanted to *and* two
wildcard_match function results.
May be someone feel comfortable with the interpreter letting doing these kind of
things. I personally prefer a more structured way of interpreting that won't
allow me to do things I don't want to do.
That's why I said it's a matter of taste. It seems Euphoria veterans prefer the
way the interpreter works.
Coming from more structured fields, I have frequently found myself messing
things up with the flexibility of Euphoria. This is why I consider this language
easier for some things and difficult for others.

Thanks for the clarifications.

JG

new topic     » goto parent     » topic index » view message » categorize

7. Re: Wildcard_match behaviour

On Tue, 30 May 2006 01:04:24 -0700, "Julio C. Galaret Viera"
<guest at RapidEuphoria.com> wrote:

>I see but... how can I technically *and* a string and a boolean result and then
>compare altogether with another string?
This is one of the pitfalls of sequence ops.
"fred" and 1 gives {1,1,1,1}
"fred" and 0 gives {0,0,0,0}
Of course, you are not likely to wildcard_match anything in that.
> Too confusing for me. Too much flexibility for my taste 
I kind of agree, but thankfully in practice this sort of error is not
too common. When a line of code does not work, break it up, eg
if w_m(xx) and w_m(yy) then ==>
debug1=w_m(xx)	--- (or think of better names)
debug2=w_m(yy)
if debug1 and debug2 then

when you trace() such code it is far easier to follow, and probably
won't actually be any slower (when run without trace) as internally
the compiler uses temporaries for complex nested expressions in pretty
much exactly the same way.

Regards,
Pete
PS Most other programming languages hold far worse horrors.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu