Eiffel "Gocha" #4 - Array items 
Author Message
 Eiffel "Gocha" #4 - Array items


an alternative to 'item' for access to an element of an array. The

'item'.

Suppose we have:

   a: ARRAY[INTEGER]
   ...
   !!a.make(1, 1)  -- make with index from 1 to 1 (i.e. one element)
   a.put(1, 1)  -- put '1' into position 1 of the array

Why can we then write this instruction...

   print(a.item(1))

..but not this one...


Answer tomorrow.

Regards,
Roger
--
--
-- Roger Browne, 6 Bambers Walk, Wesham, PR4 3DG, UK | Ph 01772-687525
-- Everything Eiffel: http://www.*-*-*.com/ | +44-1772-687525



Tue, 02 Nov 1999 03:00:00 GMT  
 Eiffel "Gocha" #4 - Array items

Roger Browne:

Quote:
> Why can we then write this instruction...
>    print(a.item(1))
> ..but not this one...




spaces.


Tue, 02 Nov 1999 03:00:00 GMT  
 Eiffel "Gocha" #4 - Array items


--
--
-- Roger Browne, 6 Bambers Walk, Wesham, PR4 3DG, UK | Ph 01772-687525
-- Everything Eiffel: http://www.eiffel.demon.co.uk/ | +44-1772-687525



Wed, 03 Nov 1999 03:00:00 GMT  
 Eiffel "Gocha" #4 - Array items

Quote:
> > Why can we then write this instruction...
> >    print(a.item(1))
> > ..but not this one...


Franck Arnaud:

Quote:


> spaces.



Even Bertrand Meyer fell for this "Gocha"! In OOSC 2nd edition, he boasts that
Eiffel uses fewer keystrokes than C to access an element of an array, yet


Regards,
Roger
--
--
-- Roger Browne, 6 Bambers Walk, Wesham, PR4 3DG, UK | Ph 01772-687525
-- Everything Eiffel: http://www.eiffel.demon.co.uk/ | +44-1772-687525



Wed, 03 Nov 1999 03:00:00 GMT  
 Eiffel "Gocha" #4 - Array items


Quote:

>Roger Browne:

>> Why can we then write this instruction...
>>    print(a.item(1))
>> ..but not this one...



>spaces.

Note that this gocha kills one of the three examples in ETL2 p68:

space before the b is easy to miss -- also (a |- f) > b looks equally
reasonable to nonmathematical people.)

Incidentally, the sanity of the definition on p. 419 depends on the
lexer convention that the longest token of a certain form is the one
that is parsed, rather than matching with a known symbol set.  This is
taken for granted in forming alphanumeric identifiers because of the
equivalent convention in most natural languages, but is IMO not as
obvious in this case for reasons visible above (we're used to breaking
streams of graphic characters into multiple tokens by eye).  Without
that convention, you can't even tokenize routine bodies until you have
determined what set of feature names is visible to each class.



Fri, 05 Nov 1999 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Eiffel "Gocha" #6 - forbidden comments

2. Eiffel "Gocha" #5 - null pointers

3. Eiffel "Gocha" #1

4. Eiffel "Gocha" #3

5. string.join(["Tk 4.2p2", "Python 1.4", "Win32", "free"], "for")

6. "copy" and drag a canvas item: strange "current" item

7. sort "items" paragraphwise

8. "Advanced" Shortcuts menu items

9. FileDrop[Combo] - Adding "Empty" item

10. Setting "checked" property on menu item

11. New canvas item "buffer"

12. AGAIN: New canvas item "buffer".

 

 
Powered by phpBB® Forum Software