The interpreter does not do (un)bound variable checking - which may be hard to realize - which means it allows something like this:

!(1, 2) => ( x, x)

Since the x strategy is executed last, this will run without any (runtime) errors. STRC gives the following error though:

variable ‘x’ used, but not bound

(which may be best, as the strategy above can be rather confusing)

Submitted on 12 February 2007 at 16:49

On 12 February 2007 at 16:55 Jira commented:

SSH-63, martin:

Some more discussion about this:

     <bravo> I'm not sure what the desired behaviour should be ;) Anyway, I think it will be difficult to 'fix' in the shell. The only way to get the strc semantics is to invoke the checking (which we don't want) or disable certain desugarings (which is not that attractive either)
     <Chip_Zero>     STRC does allow it if the variable is used as a pattern: !([1,2,3], 2) => (<fetch(?x)>, x)
     <bravo> yes, but only in a match
     <bravo> and in fact you could consider that rather confusing
     <bravo> the second x will be bound first
     <Chip_Zero>     for symmetry it would be logical if it would work for builds too... but indeed, it would probably be too confusing to allow
     <bravo> Chip_Zero: right, but this is allowed for a different reason
     <bravo> matches never result in maybe unbound warnings
     <Chip_Zero>     yeah, match can either bind a variable or compare to it

Log in to post comments