Front page | perl.perl6.users |
Postings from March 2023
Re: Undefine mixed data
Thread Previous
|
Thread Next
From:
Polgár Márton
Date:
March 21, 2023 13:51
Subject:
Re: Undefine mixed data
Message ID:
VI1P195MB001486AADC9C7DB7A3983831FE819@VI1P195MB0014.EURP195.PROD.OUTLOOK.COM
(Since this mail couldn't be delivered at first, I'll try to
aggressively split it this time...)
Dear Ralph,
I'm sorry that you get frustrated but this is still for all intents and
purposes a technical discussion so I don't think it does any good to be
vocal about it. There are good points and bad points, arguments and
counter-arguments. I can also get upset when I feel indifference or
dishonesty in a response that's meant to be an argument but I think a
thread like this should read like valuable technical content to an
"outsider".
>> you cannot reasonably indicate for an array that it doesn't have
>> valid content, as opposed to being empty by chance
> If you mean indicate it's undefined, then here's one way:
> ```
> my @array;
> say @array.elems; # 0
> say @array.so; # False
> say @array.defined; # True
>
> say @array := Array:U; # (Array:U)
> say @array.so; # False
> say @array.defined; # False
> ```
> If you mean something else, please be specific.
First, it's both inconsistent and inconvenient to have to explicitly
bind the variable. Second, once you bound it to the undefined (and
indefinite) value, you cannot store elements into it by assignment
anymore (there is no auto-vivification either) - so at the end of the
day, this is a very similar solution to giving up on @variables
altogether, except here you give up on assignment altogether. However,
if you want to modify a part of a composite data structure via a
container (say, a value you retrieved using .values or some sort of
mapping), binding won't help you; you just spoil your own reference to
the data you wanted to alter. Again, something that works well for
Scalars but nothing else.
Thread Previous
|
Thread Next