[#3986] Re: Principle of least effort -- another Ruby virtue. — Andrew Hunt <andy@...>

> Principle of Least Effort.

14 messages 2000/07/14

[#4043] What are you using Ruby for? — Dave Thomas <Dave@...>

16 messages 2000/07/16

[#4139] Facilitating Ruby self-propagation with the rig-it autopolymorph application. — Conrad Schneiker <schneik@...>

Hi,

11 messages 2000/07/20

[ruby-talk:04146] Re: String range inconsistence

From: Charles Hixson <charleshixsn@...>
Date: 2000-07-20 15:34:38 UTC
List: ruby-talk #4146
Sergey Abel wrote:

> Hi,
>
> "z".succ == "aa", but "z" > "aa".
> As a consequence, ("z".."aa").size == 0 instead of 2.
> (Same with upto method, for that matter.)
>
> The reason is clear: it's "unnatural" succ definition.
> (BTW, "\000".succ == "\001\001". Wow.)
>
> IMHO, this has been conceived as the method for "plain letters",
> not for arbitrary strings. If so, isn't this a subject to discuss?
>
> Does the language need a special subclass (encoding-dependent?)
> for such strings and/or methods?
> How to cope with punctuation, e.g. should we expect "a:".succ == "b:"?
>
> Sergey Abel

The problem is, there is a range of plausible interpretations, each valid
in it's particular domain.  E.g. (my apologies for not having mastered the
syntax yet):
"a:".succ == "b:"
"a:".succ == "a"+":".succ
"alpha".succ="beta"
etc.

Perhaps the thing to do is to define some basic class, and to allow the
various interpretations to be the result of sub-classing.  That would,
however, make it more difficult to present the constant values in the
code.  Perhaps:
LetS.val("a:").succ == LstS.val("b:")
StrS.val("a:").succ == StrS.val("a")+StrS.val(":").succ
GrkA.val("alpha").succ == GrkA.val("beta")

but that certainly looses a lot of the simplicity.  Perhaps a "block cast"
for operators could be devised, along the lines of:
with (\", \+) from LetS do
   val = "a:".succ        ## Assert that val == "b:"
end

This would mean that within the block encompassed by the do, end the
operators " and + would be understood to have the meaning assigned to them
by the class LetS.  Probably not worthwhile, as it can already be
accomplished by the creation of temporaries (which I noted above as, e.g.,
LetS.val("a:").  But it might have other applications.  I just can't think
what they would be.

-- (c) Charles Hixson
--  All commercial rights reserved
--  Addition of advertisements or hyperlinks to products specifically
prohibited

Attachments (1)

charleshixsn.vcf (145 Bytes, text/x-vcard)
begin:vcard 
n:Hixson;Charles
x-mozilla-html:FALSE
adr:;;;;;;
version:2.1
email;internet:charleshixson@earthling.net
fn:Charles Hixson
end:vcard

In This Thread

Prev Next