[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-hackers] substring function and bounds checks
From: |
Michele La Monaca |
Subject: |
[Chicken-hackers] substring function and bounds checks |
Date: |
Tue, 5 Feb 2013 23:11:51 +0100 |
Maybe this is not the right list for that, sorry. But is there a good
reason for this behavior?
# perl -e 'print substr("ciao",0,10);'
ciao
# ruby -e 'puts "ciao"[0..10]'
ciao
# python -c 'print "ciao"[0:10];'
ciao
# csi -e '(print (substring "ciao" 0 10))'
Error: (substring) out of range 0 10
Call history:
<syntax> (print (substring "ciao" 0 10))
<syntax> (substring "ciao" 0 10)
<eval> (print (substring "ciao" 0 10))
<eval> (substring "ciao" 0 10) <--
I find it rather inconvenient and I can't really see any good reason
to do that. In fact, it makes the usage of substring "unsafe" and the
countermeasures I can imagine (manual bounds checks, padding, writing
my-own-substring-function, whatever) are quite unsatisfactory... to me
at least.
Regards,
Michele
- [Chicken-hackers] substring function and bounds checks,
Michele La Monaca <=
Re: [Chicken-hackers] substring function and bounds checks, Moritz Heidkamp, 2013/02/05