On 2020-05-31 04:58, Peter Pentchev wrote:
So my beef is when you feed these guys an undefined
variable, that they needs to tell you it requires
a "defined" variable. Not a bunch of useless rubbish.
For example (useless rubbish):
And also... I thought I mentioned this before. You want a more clear
error message for*one* *single* specific case of a "can't find this
method, did you mean one of these?" error message. I tried to explain
that this error message is one that is displayed in many cases, not only
for "you passed an undefined thing, I want a defined thing"; in my
opinion, it is actually quite helpful in that it actually lists
the candidates in a "did you mean one of these?" style.
You want it to be clear if you pass an undefined value where a defined
value was expected; that would mean that somebody would have to write
the code to make it check whether it is this very specific case and then
that code would have to be maintained for years and years. Tomorrow
you'll say "but can't it give me a more clear message when I pass an
integer and it expected a string?" and the day after tomorrow you'll say
"but can't it give me a more clear message when I pass a string and it
expected a function?".
The error message says "you passed an object of this type, and I can't
find this method for this type; here are a couple of types that have
this method, did you mean one of these?" It tells you what the types
are, and it doesn't have to have thousands of special cases. It tells
you what the types are.
Hi Peter,
I like that you in-line and bottom post. You are a lot
easier to follow.
I think are talking at cross purposes. Let me give an
example:
Q: is a "cow" a "Plant"?
A: a "cow" in not a hazel nut
A: a "cow" in not a radish
A: a "cow" in not a carrot
A: a "cow" in not a cabbage
...
Are all of the answers a correct?
Yes.. Evey answer is completely correct.
Are any of the answers helpful?
No
I do believe you are telling me the above answers
are useful. They may be if a certain sense, but
not at all useful in troubleshooting.
What I am after is:
Q: is a "cow" a "Plant"?
A: No
Now when I code, I spend at least 50% of my time double
checking the validity of what the user entered. If
I require a windows drive to be in the format of "A:\",
I am going to check that index 0 is "a...z, A..Z", that
index 1 is ":", and that index 2 is "\". If it fails,
I am going to say why, not give alternate uses of
the invocant: A: a "cow" in not a turnip
Now the manual says (I am not a big fan of the manual,
but I do use it):
https://docs.raku.org/routine/starts-with
multi method starts-with(Str:D: Str(Cool) $needle,
:i(:$ignorecase), :m(:$ignoremark) --> Bool:D)
It clearly states that the haystack (invocant) is
a defined string (Str:D) and it is required to
be to operate correctly.
The message you get back, does to say anything about
violating the requirement, but just give information
on other uses of the haystack (invocant).
A: a "cow" in not a pepper.
A: a "cow" in not a onion
A: a "cow" in not a pine tree
A: a "cow" in not a tumble weed
What I would like to see (that is a suggestion, not a
demand) come back would be something like:
starts-with's invocant requires a defined value (Str:D)
Much more useful. Not a list of all the types the
method can handle. No chasing the wrong rabbit
down the wrong hole.
Thank you for all the help and tips!
-T
A: a "cow" in not a onion
A: a "cow" in not a pine tree
would you please stop?
A: a "cow" in not a tumble weed
NO! I have 500 more to go!
A: a "cow" in not a tomato
A: a "cow" in not a pot...
<ctrl>
DON'T YOU DARE!
atoe
<C>
AAHHHH Curses on y.... <silence>