[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Why (substring "abc" 0 4) does not return "abc" instead of an error?
From: |
Bastien |
Subject: |
Re: Why (substring "abc" 0 4) does not return "abc" instead of an error? |
Date: |
Mon, 16 Jul 2012 16:40:37 +0200 |
User-agent: |
Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.1.50 (gnu/linux) |
Hi Pascal,
"Pascal J. Bourguignon" <address@hidden> writes:
> (defun mysubstring (str start end)
> (substring str (max start 0)
> (if end
> (min end (length str))
> (length str))))
>
> and use (mysubstring "abc" 0 4) --> "abc"
> instead of substring.
I know how to implement my own defun for this but thanks.
My question was about what _justifies_ the current behavior.
Dmitry said at least JS, Ruby, Python and perhaps C++ uses
the behavior I mention -- so I'm even more curious now.
I am not saying the behavior I expect is superior, it is
just the one I expect -- I would like to read a good reason
for the current one. Juanma have a point when he said that
the current behavior is consistent with other *-substring
functions but again, `substring' seems different to me.
> The point of lisp is to let you define your own language seamlessly.
True.
But the point of sharing code is also to not reinvent the
wheel, right?
Best,
--
Bastien