Replies: 4 comments 2 replies
-
Some variables never fall out of scope until global cleanup. |
Beta Was this translation helpful? Give feedback.
-
This case is what I was writing about earlier - first we should have full set of feature where we want to go and then split it into smaller steps. In this particular case I voted for something else - that means do more preparation tasks. What you actually described is actually completely different problem, imagine:
now:
Counterexample to imposing contract:
|
Beta Was this translation helpful? Give feedback.
-
Moo has a similar issue, that types applied to attributes only check on direct assignment to the attribute. Points to I think it's surprising behavior to declare some check, and then write code that assumes the check is true, only to find out later that your assumption was simply wrong. It's a false sense of security, and actually a step back (it's kinda like my experience using AI to help write code, it lulls you into a false sense of security + then you push bugs into prod. multiple times) |
Beta Was this translation helpful? Give feedback.
-
(I just discovered this reply with about 1.5 sentences written in a browser tab. I thought I'd already hit "post" days ago sigh) I voted "something else" but for most practical purposes I'm a "yes". The something else is add a keyword |
Beta Was this translation helpful? Give feedback.
-
@druud @happy-barney @perigrin @rabbiveesh @rwp0 @SysPete @tobyink @demerphq
This is probably the most contentious issue. The attribute poll strongly rejected attributes. The casing poll leaned towards built-in checks being SHOUTY, with title-cased being a second option. To my surprise, no one voted for lower-case built-in checks. We have one last "major" thing to decide on before I can write a spec.
We currently have the following syntax proposed:
In the current spec, if we do
$hash{some_key} = \%something
, it instantly fails because that is not an arrayref. Same for$hash{some_key} = [1,2,3,4];
. However,$hash{some_key}[0] = \@some_array
would silently succeed because we didn't assign directly to the variable.This poses a problem.
my ARRAY[HASH[INT]] %hash
doesn't guarantee that we have arrayrefs of hashrefs of integers. This is because the check is attached to the variable, not to the potentially deeply nested values. Why?The idea is that for the MVP, we only validate against direct assignments to the variable.
However, it means that a declared check isn't really a guarantee. No one is happy with the trade-off. What should we do?
As a third option, I thought about re-validating the check across the entire data structure when a variable falls out of scope. We won't necessarily see the error when it happens, but we'll see the error. It's a rubbish compromise, but it seems better than nothing. However, while it seems a reasonable compromise, I can't help but think there are edge cases I haven't considered (that's often the case).
4 votes ·
Beta Was this translation helpful? Give feedback.
All reactions