Confused about "identical"

aAComparison

a!A A1a Comparison

The above blocks produce TRUE. Why?
Unicodes are different for a and A: 97 and 65.

HELP for the block says that it's mainly for list comparisons.
Then should it refuse any other kind of input?

Thx.

You're right, it would be useful to have a way to do a case-sensitive comparison, and we might as well use the IDENTICAL block.

For lists, the block is the Lisp EQ? -- that is it's true only if the two inputs are the same location in memory. But for non-mutable data, it would confuse people if 3 and 3 weren't identical. (Although maybe we should also take the opportunity to make 3 and 3.0 non-identical.) We just didn't bother thinking through what "identical" should mean for types other than lists.

I guess also, in Lisp, EQ? is super-fast because it's a single address comparison, and the fact that it often reports TRUE for non-list equal data just falls out from other optimizations that Lisp systems generally make. So an old Lisper like me understands automatically what IDENTICAL is for. But I guess we shouldn't assume all our users are like me. :slight_smile:

By the way, if you shift-right-click on a block, one of the menu options is "script pic with result."

Speaking for myself only, I'm nowhere near like you - and that is meant as a compliment.

That is very handy! Thanks for the tip.

1 Like

Ah, I didn't mean "smart like me," I meant "old like me." I started hacking computers in the early days of Lisp.

I think that the block should be

function (a, b) {return a == b; }

or

function (a, b) {
    if (this.isImmutable(a) && this.isImmutable(b)) {
        return a.asString() === b.asString();
    }
    return a === b; // why doesn't the builtin use this?
}

Both to you, and the OP, put alt's in your images.

i recreated it so it senses capitals (and much more) . here's the link
now it saysis  identical to , remade to sense capitals script pic and is  identical to , remade to sense capitals script pic (1)

I've made a block to test whether they are exactly the same

I have remade that block. You can find it here- https://snap.berkeley.edu/snap/snap.html#present:Username=r4356th&ProjectName=Snap!BL&editMode&noRun .

Yup, that works for characters, but not for lists, etc.

Yeah, because I am using the Unicode. Is it possible to find the Unicode of lists?

There's no such thing as "the Unicode of lists." Unicode is a representation for text characters. Lists are a whole different kind of data.

Well, what I mean is Unicode of the items in lists.

That would work if the items in the lists are text strings, but list items can be lists, blocks, scripts, costumes, sounds, numbers, etc.

I see. Thank you.
Did I get the topic off-topic? Sorry if so.

you probobly don't know this, but the unicode of block only gets the unicode of the first character, not the whole string. this block Snap!BL script pic reports true., but with my block, it reports false.

Ah, but wait until Snap! 6.0. :~)

with what? the unicode of block?

EDIT: I just tried it out (the snap 6.0 beta) and, wow, love it, now I won't have to use my identical block.

I really did not know that! I also did not test with a word or any other thing. I will try to make a better one with less complex code than your one(no offense meant).

Do you mean unicode of the whole string or the unicode of the block (I am confused about what @ego-lay_atman-bay means by that)?