Faulty implementation or not? 
Author Message
 Faulty implementation or not?

This is my first posting to this group and I hope you'll treat me kindly
even if I am being stupid.

Please consider this code...

(define G 9)

(define foo
        (lambda V
            (do ((i 0 (+ i 1)))
            ((>= i (length V)) #t)
            (display (list-ref V i))
            (newline)
            )
        )
)

(foo 3 2 1G) ; Note the lack of whitecap between the 1 and the G

On the implementation that I use, the resulting output is...

3
2
1
9

In other words, the parsing of 1G "stops" when G is seen and evaluates
it to a numeric constant of 1. However, it then considers G to be a new
parameter. In this contrived case, G exists hence the resulting output.

My question is whether this is a valid Scheme implementation. I would
have intuitively reckoned that 1G should be seen a one (non-existent)
parameter. I've looked at the formal syntax but it'll take me ages to
figure it out from there.

Any ideas anyone?



Tue, 02 Jul 2002 03:00:00 GMT  
 Faulty implementation or not?

Quote:

> Please consider this code...
[...]
> (foo 3 2 1G) ; Note the lack of whitecap between the 1 and the G
[...]
> In other words, the parsing of 1G "stops" when G is seen and evaluates
> it to a numeric constant of 1. However, it then considers G to be a new
> parameter. In this contrived case, G exists hence the resulting output.

> My question is whether this is a valid Scheme implementation. I would
> have intuitively reckoned that 1G should be seen a one (non-existent)
> parameter. I've looked at the formal syntax but it'll take me ages to
> figure it out from there.

R5RS (Sect. 7) says that a identifier doesn't start with a
number.  Also, it specifies intertoken-space with a kleene star,
which means that there can be none of it.  So your implementation
is right in what it does ("1G" being read as "<number 1>" and
"<identifier G>"), but i wouldn't rely on this "feature", and use
whitespace liberally, and no identifiers which start with a
number.

HTH,
        -- forcer

--




Tue, 02 Jul 2002 03:00:00 GMT  
 Faulty implementation or not?
On 14 Jan 2000 17:44:45 +0100, Jorgen `forcer' Schaefer

Quote:

>R5RS (Sect. 7) says that a identifier doesn't start with a
>number.  Also, it specifies intertoken-space with a kleene star,
>which means that there can be none of it.

However, the third paragraph of 7.1.1 says:

"Tokens which require implicit termination (identifiers, numbers,
characters, and dot) may be terminated by any <delimiter>, but not
necessarily by anything else."

The "not necessarily" clause muddies the waters, of course, but the
statement certainly suggests that it is appropriate for such tokens to
be separated by <delimiter>s.

-Steve



Tue, 02 Jul 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Clipper.lib Faulty

2. implementations of logo not in english

3. Occam implementations that do not target the transputer

4. faulty procedure

5. triple-fault faulty

6. Faulty Pentiums

7. Faulty IFNAN in MS Fortran Powerstation?

8. Faulty languages and Liability

9. faulty array bounds checking

10. ACL elt faulty?

11. segmentation error with faulty stipple Bitmap

12. Tcl 7.6 fCmd.test 6.23 and 6.28 faulty for Linux and other OS's

 

 
Powered by phpBB® Forum Software