This channel is intended for people just starting with the Raku Programming Language (raku.org). Logs are available at irclogs.raku.org/raku-beginner/live.html Set by lizmat on 8 June 2022. |
|||
01:18
cleo left
03:32
sdomi left,
sdomi joined
03:54
jgaz left
03:57
tonyo left
03:58
tonyo joined
04:16
codesections left,
codesections joined
04:28
hythm joined
05:52
hythm left
08:05
cleo joined
13:02
lucs left
13:03
lucs joined
14:22
dakkar joined
14:23
dakkar left
14:43
stanrifkin joined
|
|||
stanrifkin | Is there a way to check if an variable is immutable? | 14:43 | |
constant $var = 31; if $var.mutable { ... } | 14:44 | ||
librasteve | short of a CATCH block, I don't know ... good question! | 14:50 | |
ok this seems to work: constant $x =3; say $.VAR.WHICH; #Int|3 | 14:52 | ||
my $y = 42; say $y.VAR.WHICH; #Scalar|3768135182992 | 14:53 | ||
$x.VAR ~~ Scalar #False | 14:54 | ||
$y.VAR ~~ Scalar #True | |||
this works because all the non-container forms of a "variable" are really terms and binding (constant, my \x =42) | 14:56 | ||
so you are looking for a (Scalar) container to find mutability | |||
this docs.raku.org/type/ValueObjAt does the job for Positionals that may contain mutable containers | 14:57 | ||
stanrifkin | librasteve: thank you | 14:59 | |
15:27
stanrifkin left
|
|||
gfldex | m: my $thing := Proxy.new: FETCH => my method { $ } , STORE => my method (|) {}; sub foo($x is rw) { say $x.VAR.WHAT; }.($thing); | 15:33 | |
camelia | (Proxy) | ||
gfldex | @librasteve: It can also be a Proxy, however, you can't really know if that definite Proxy allows STORE. | 15:34 | |
librasteve | ah yes - thanks .... so is there a more MOPpy way to check eg, for an l-value role? | 15:36 | |
gfldex | You have to descent into NQP-land and check the descriptor. With RakuAST you could use a macro to check the declaration (and its context) of the symbol. | 15:52 | |
librasteve | tx | ||
19:56
MasterDuke joined
21:55
habere-et-disper joined
22:49
habere-et-disper left
|