Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

length? of issue! #1740

Closed
Siskin-Bot opened this issue Feb 15, 2020 · 1 comment
Closed

length? of issue! #1740

Siskin-Bot opened this issue Feb 15, 2020 · 1 comment
Labels

Comments

@Siskin-Bot
Copy link
Collaborator

Submitted by: Sunanda

in R2 and until recently in R3:
    length? #1
    == 1

Now in R3:

    length? #1
    == 2

Intentional?

1 = length? #1

Imported from: CureCode [ Version: alpha 110 Type: Issue Platform: Windows Category: Datatype Reproduce: Always Fixed-in:none ]
Imported from: metaeducation#1740

Comments:

Rebolbot commented on Nov 5, 2010:

Submitted by: meijeru

I would argue there is consistency with the other types in any-word!

>> length? /a
== 2
>> length? quote :a
== 2

Rebolbot commented on Nov 5, 2010:

Submitted by: Sunanda

That makes some sense....If, conceptually, the length of a word! is its molded form.

But then length? :a is a little anomaly...perhaps its length should be zero when a has no value

mold /a
== "/a"
mold #a
== "#a"
mold :a
== "unset!"        ;; so why a length of 2!?

Rebolbot commented on Nov 5, 2010:

Submitted by: meijeru

You will notice I programmed length? quote :a, just to avoid the unset! problem. You should try mold quote :a, it has a length of 2 allright. The refinement and the issue do not need to be quoted because they are never further evaluated (they are pure literals).


Hostilefork commented on Apr 11, 2019:

This is resolved in Ren-C because ISSUE! is returned to an ANY-STRING!:

metaeducation/ren-c#980

Allowing one to directly take the length of an ANY-WORD! was tried for a while. Letting words be treated as a kind of read-only series (without a position) has some benefits, but also runs risks of having a symbol be processed accidentally as being something other than atomic.

It is legal in Ren-C to alias the underlying UTF-8 data of an ANY-WORD! into a string cell without making a copy...so as text! 'foo gives you "foo" as a read-only string. Hence, this is what you should do for now instead of directly trying to take the length of a word (or iterate it with FOR-EACH, etc.)


Hostilefork added the Ren.resolved on Apr 11, 2019


@Oldes
Copy link
Owner

Oldes commented Mar 30, 2020

length? of issue! (like with other word types) is counted as length of bytes (not code-points) plus 1 (decoration).
It is described here: #2224

>> length? #ša
== 4

>> length? to-binary "ša"
== 3

@Oldes Oldes closed this as completed Mar 30, 2020
@Oldes Oldes reopened this Mar 30, 2020
@Oldes Oldes added the Oldes.resolved Bugs/wishes with Oldes' fixes/features label Mar 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants