00:17
SrainUser joined
|
|||
SrainUser | I passed an array of strings to a field of an object, then I printed that array from a method within that class, but the array printed is empty. Is there a certain syntax for accessing array attributes within classes? | 00:26 | |
guifa | 5rainUser: not really, it sounds like for some reason it's not binding during creation | 00:29 | |
can you post your code? | |||
m: class Foo { has @.text; method print { say @!text.join } }; my $foo = Foo.new(text => <a b c d>); $foo.print | 00:30 | ||
camelia | abcd | ||
SrainUser | class Class { | 00:31 | |
has @!arr; | |||
method yo() { | |||
say @!arr; | |||
} | |||
} | |||
my @array = ["hello", "goodbye", "what"]; | |||
my $example = Class.new( | |||
arr => @array | |||
); | |||
$example.yo(); | |||
ab5tract | @!arr is defined as a private instance variable | 00:32 | |
You can set it manually via a method new / submethod BUILD / submethod TWEAK | |||
guifa | just change it to has @.arr (will make it by default settable via .new) or you can also use `has @!arr is built`, or you can do the adjustments as ab5tract notes in BUILD or TWEAK | 00:33 | |
ab5tract | but if you define it as @.arr it becomes public and the default new / BUILD implementations will make it work as you currently are creating the $example object | ||
SrainUser | Thanks! | 00:34 | |
00:43
tejr left
|
|||
SrainUser | I this a bug?: | 01:40 | |
my @array1; | 01:41 | ||
my @array2 = [["hello", "goodbye"], True]; | |||
@array1 = @array2[0]; | |||
say @array1; | |||
Prints a list inside a list. | |||
01:44
Aedil joined
|
|||
SrainUser | A temporary solution is: | 01:59 | |
my @array1; | |||
my @array2 = [["hello", "goodbye"], True]; | |||
for @array2[0][0..*] -> $item { | |||
@array1.push($item); | |||
} | |||
say @array1; | |||
phogg | I was porting a Perl module today and found myself missing wantarray. What do people do instead? | 02:06 | |
02:06
guifa left
02:09
guifa joined
|
|||
SmokeMachine | m: my @array1; my @array2 [[“hello”, “goodbye”], True]; @array1 =@array2[0]; say @array1 | 02:21 | |
camelia | ===SORRY!=== Signatures as constraints on variables not yet implemented. Sorry. at <tmp>:1 ------> my @array2 [[“hello”, “goodbye”], True]<HERE>; @array1 =@array2[0]; say @array1 Other potential difficulties: Literal values in s… |
||
SmokeMachine | m: my @array1; my @array2 = [[“hello”, “goodbye”], True]; @array1 =@array2[0]; say @array1 | 02:22 | |
camelia | [[hello goodbye]] | ||
SmokeMachine | That looks correct to me… | ||
m: my @array1; my @array2 = [[“hello”, “goodbye”], True]; @array1 := @array2[0]; say @array1 # SrainUser is this what you want? | 02:24 | ||
camelia | [hello goodbye] | ||
SmokeMachine | m: my @array1; my @array2 = [[“hello”, “goodbye”], True]; @array1 = |@array2[0]; say @array1 # Or maybe this? | 02:25 | |
camelia | [hello goodbye] | ||
SmokeMachine | m: my @array1; my @array2 = [[“hello”, “goodbye”], True]; @array1 = @array2[0][]; say @array1 # not sure about this one… | ||
camelia | [hello goodbye] | ||
SrainUser | Yes, although why would it not work with the assignment operator? | 02:27 | |
SmokeMachine | SrainUser: @array2[0] returns an item that in this case is an array, so it’s put as an item inside the other array | 02:28 | |
m: my @array = [[“bla”, “ble”], True]; dd @array[0]; dd @array[0][] | 02:29 | ||
camelia | @array = $["bla", "ble"] ["bla", "ble"] |
||
SmokeMachine | SrainUser: compare the difference: ^^ | 02:30 | |
ab5tract | In other words, @foo[] is a slice | 02:31 | |
m: my @a = [1,2], True; dd @a[0], @a[0][], @a[0][*] | 02:33 | ||
camelia | @a = $[1, 2] [1, 2] (1, 2) |
||
SmokeMachine | phogg: what was the case you needed the wantarray? | ||
SrainUser | That is rediculous. I don't want a slice. I want the first element of the array. | 02:40 | |
phogg | SmokeMachine: a method returning a list of words or the same list joined on a string (in a scalar context) | ||
it would be easy if return type was used as part of method dispatch | 02:41 | ||
02:46
ming joined
02:47
hulk joined
02:48
kylese left
|
|||
SmokeMachine | What about something like `return <bla ble ble> but role { method Str { $.join } }`? | 02:59 | |
m: sub a { <bla ble ble> but role { method Str { $.join } } }; say a; say “{ a }” | 03:00 | ||
camelia | (bla ble ble) blableble |
||
SmokeMachine | phogg: ^^ | 03:01 | |
timo | SrainUser: when stuff is put into an array, every entry gets a scalar container, so when you take the first element out of @array2 you're getting back a single item that you're assigning to @array1. you'll want to .list, or <> to decont, or [], or something else to get rid of the container that protects it from being iterated while assigning to @array1. another thing you can do is bind instead of | 03:08 | |
assign to @array1 with the := operator | |||
03:10
ming left
|
|||
phogg | SmokeMachine: yeah that was what I was thinking, but it seems kind of hacky. Looking for best practice advice. | 03:11 | |
I will have a handful of similar methods and I don't like the look of all of that inline. When does it become reasonable to make a custom type instead? | 03:13 | ||
03:15
hulk left
|
|||
SrainUser | So it doesn't copy the value of the item, it points to the item in the container (or array), or it creates a new container for the value of the item. | 03:15 | |
03:15
kylese joined
03:17
yewscion joined
|
|||
timo | when you bind, yes you'll end up with the same item living inside @array2 that now has the "extra name" @array1 | 03:20 | |
when you assign an array to an array variable, you'll get fresh scalar containers for the elements in it, which is important to know | |||
i guess it would be quite surprising if it were different | 03:21 | ||
03:23
stackspace left
|
|||
ab5tract | phogg: my recommendation would be to write two multi candidates and use a named argument to distinguish between the two | 03:27 | |
phogg | if I could I would | 03:28 | |
ab5tract | What do you mean? | ||
03:28
Aedil left
|
|||
phogg | Doing that would change the API. I'm trying not to. | 03:28 | |
if I'm changing the API I can just use different method names | 03:29 | ||
ab5tract | Sure, doing that versus adding an adverb is a matter of taste | 03:30 | |
I guess I don’t know enough about your use case to provide valuable input | 03:31 | ||
That said, if I were stuck with an API I couldn’t change, I would probably just wrap it with a local sub. | 03:33 | ||
Either way, if the call site knows what it wants, it can call a specialized version of the code to get what it expects. wantarray has been an anti pattern for a | 03:34 | ||
03:45
Aedil joined
|
|||
ab5tract | * few decades already | 03:52 | |
04:40
yewscion left
04:42
yewscion joined
04:45
yewscion left,
yewscion_ joined
04:48
yewscion_ left
04:49
yewscion joined
05:22
SrainUser left
06:15
yewscion left
06:16
guifa left
07:16
ulipink joined
07:17
ulipink left
07:18
ulipink joined,
ulipink left,
ulipink joined,
Sgeo left
08:22
sorenson_ joined
08:23
sorenson left,
sorenson_ is now known as sorenson
09:11
dakkar joined
09:54
sena_kun joined
|
|||
patrickb | Is there a module to set up an ad hoc ecosystem from a local folder with a few module repos checked out? | 11:48 | |
I have a few interdependent modules I'd like to test installation of. So only installing one of them won't work as it depends on the others. | 11:49 | ||
lizmat | I usually bump the versions of the modules locally, and just install them locally when testing that one module | 11:52 | |
one of the advent posts described a content management system | 11:53 | ||
raku-advent.blog/2024/12/13/day-13...ributions/ | 11:54 | ||
patrickb | But I'm concerned about the dependency specifications those I want to test. So I want zef to be able to resolve and install the dependencies. | 11:57 | |
It should be pretty trivial to write a ecosystem generator, right? I basically only have to copy together all the META6.json files, right? | 11:59 | ||
antononcube | Is using Docker an alternative ? Generating a dockerfile with the required packages and versions should be easy. | 12:01 | |
lizmat | hmmm.. create a CURFS with a standard prefix, install the dependencies to that with zef --to (I believe), and then use that standard prefix with -I always ? | ||
12:03
ulipink left
|
|||
patrickb | Nah, I can just install to the default locations. That's fine. I'm only interested in the installation process itself, not the resulting installation. | 12:04 | |
I think I'll just hack something up. Thanks everyone for chiming in. | |||
12:52
ulipink joined,
ulipink left,
ulipink joined
12:57
ulipink left
13:22
guifa joined
|
|||
[Coke] | docs.raku.org/syntax/wantarray%20-%20perlfunc | 13:26 | |
13:59
ulipink joined,
guifa left
14:01
guifa joined
14:04
ulipink left
14:07
hudo_ left
14:08
hudo joined,
hudo_ joined
14:33
ulipink joined,
ulipink left,
ulipink joined
14:38
ulipink left
14:53
ulipink joined,
ulipink left,
ulipink joined
14:57
ulipink left
15:28
ulipink joined
15:33
ulipink left
16:07
ulipink joined
16:12
ulipink left
16:15
Manifest0 joined
16:41
ulipink joined
16:46
ulipink left
16:47
SrainUser joined
16:48
SrainUser left
16:52
Simba111 joined
17:28
yewscion joined
17:29
ulipink joined,
ulipink left,
ulipink joined
17:33
ulipink left
17:37
dakkar left
|
|||
ugexe | patrickb: I would look at these | 17:44 | |
github.com/ugexe/zef/blob/main/xt/...y.rakutest | |||
github.com/ugexe/zef/blob/main/lib...od#L16-L34 | |||
The slightly harder part is getting `zef` to see those type of custom repositories, but if the above links make sense it should be trivial for you to modify the synopsis code here to use instead `bin/zef`: github.com/ugexe/zef/blob/080304e1...od#L26-L49 | |||
alternatively you can add a Zef::Repository::Ecosystems entry in the config file similar to the fez one, and point the mirror at a file (instead of a url) that is an array of hash (an array of meta6.json data) | 17:45 | ||
there is also github.com/tony-o/raku-zeco being worked on (or rather more like waiting for me to review it more) which spins up a docker container with fez ecosystem software which could then be used as the mirror/url for an ecosystem in the zef config | 17:49 | ||
lizmat | and there's raku.land/zef:lizmat/Zef::Configuration :-) | 17:58 | |
18:03
ulipink joined
18:09
ulipink left
18:24
ulipink joined
18:28
ulipink left
18:43
ulipink joined,
ulipink left,
ulipink joined
|
|||
patrickb | ugexe: Thanks for the hints! I plan to create a tiny script that copies together a valid ecosystem.json and then add an entry to the zef config. | 18:45 | |
18:47
ulipink left
18:50
msiism joined
|
|||
msiism | Is there a way to customize the Rakudo prompt? | 18:51 | |
jdv | the repl one? | 18:53 | |
msiism | Yes. | 18:54 | |
I'd like to disable the line count. | |||
jdv | idk. override interactive_prompt? | 18:58 | |
github.com/rakudo/rakudo/blob/6363...kumod#L411 | |||
msiism | Hm… I was more looking for run-time configurability. | 19:01 | |
It not all that tragic to have the line numbers in there. It's just that I often copy examples from the REPL into my notes and then have to filter them out. | 19:03 | ||
19:03
ulipink joined
|
|||
antononcube | Hmmm... this might mean, that you have to use different REPL. | 19:03 | |
For example, notebooks. | 19:04 | ||
jdv | you could submit a feature req or a pr but idk if itd get in | ||
[Coke] | lizmat did some work to help customize the REPL previously - I think having something pull from an env var there might be worth considering. | ||
msiism | Yeah, that's what I was thinking. | 19:05 | |
lizmat is thinking waterbed | 19:06 | ||
[Coke] | msiism: github.com/Raku/problem-solving ? | ||
lizmat | the line numbers (actually result numbers) were added to be able to refer to previous values by means of $*0, $*1, etc | 19:07 | |
antononcube | For example, "Jupyter::Chatbook" notebooks take (i) a Raku file with initialization code, and (ii) a JSON file with LLM personas. | ||
19:07
ulipink left
|
|||
msiism | [Coke]: Okay, I'll see what I can do. | 19:07 | |
antononcube | And notebooks support In[1] and Out[12] type of references for previous inputs and outputs. | 19:08 | |
msiism | lizmat: I see. | ||
[Coke] | so that might correspond to %*ENV{RAKU_REPL_PROMPT} = '[{$N}] > ' as a default? | ||
lizmat | [Coke]: possibly yes, issue / PR welcome | ||
[Coke] | msiism: if you open that problem solving ticket, I can see about putting together a PR | 19:09 | |
msiism | Okay, nice. I won't be able to get to that today, but withing the next days should be possible. | 19:10 | |
lizmat | ++msiism | ||
antononcube | Using Raku file with initialization code is not in "Jupyter::Kernel" yet -- I have to file an issues so bduggan would implement it. | 19:11 | |
19:37
Aedil left
19:39
ulipink joined
19:44
ulipink left
20:26
yewscion left
20:30
ulipink joined
20:34
ulipink left
20:41
yewscion joined
|
|||
msiism | If `||` "returns the first argument that evaluates to True in Boolean context" and "otherwise returns the last argument", why does `'Alpha' || 'Beta'` return `Alpha`? | 20:49 | |
ugexe | because 'Alpha' evaluates to True in Boolean context | ||
m: say so 'Alpha' | |||
camelia | True | ||
msiism | Okay, but why? | 20:50 | |
lizmat | because that was so decided | 20:51 | |
ugexe | docs.raku.org/syntax/Boolean%20context | ||
"In general, non-zero, non-empty will be converted to True; zero or empty will be equivalent to False. But .so can be defined to return any Boolean value we want, so this is just a rule of thumb." | |||
msiism | I see, thanks. | ||
21:04
ulipink joined
|
|||
Geth | ecosystem/main: b3f73ae412 | (Elizabeth Mattijsen)++ | META.list Remove two of Kamil Kułaga's distributions They have bitrotted, and one of them interferes with the new Test::Coverage distribution |
21:07 | |
21:08
ulipink left
21:39
ulipink joined
21:43
ulipink left
21:57
Xliff joined
|
|||
Xliff | m: my \💩 = 69; say 💩 | 21:57 | |
camelia | ===SORRY!=== Error while compiling <tmp> Malformed my at <tmp>:1 ------> my<HERE> \💩 = 69; say 💩 |
||
Xliff | O_o .... NOoooooooo! Whyyyy! My hopes for this years April Fool's is dashed! | 21:58 | |
No. Seriously. Why is that symbol not allowed? | |||
I mean, I know it loosely translates to "My crap is pr0n" but c'mon!!! | 22:00 | ||
guifa | m: my term:<💩> = 69; say 💩 | 22:02 | |
camelia | ===SORRY!=== Type 'term:<💩>' is not declared at <tmp>:1 ------> my term:<💩><HERE> = 69; say 💩 Malformed my at <tmp>:1 ------> my term:<<HERE>💩> = 69; say 💩 |
||
guifa | my sub term:<💩> = {69}; say 💩 | ||
m: my sub term:<💩> = {69}; say 💩 | |||
camelia | ===SORRY!=== Error while compiling <tmp> Missing block at <tmp>:1 ------> my sub term:<💩><HERE> = {69}; say 💩 expecting any of: new name to be defined |
||
guifa | m: my sub term:<💩> {69}; say 💩 | ||
camelia | 69 | ||
guifa | there you go | ||
Xliff | \o | 22:05 | |
guifa: \o/ You've saved my 4/1 # I muzt troll! | |||
guifa | I guess you could just do sub term without the my too | 22:06 | |
depends on the scope :) | |||
Xliff | Yah. Thanks! | ||
22:28
msiism left
22:34
kjp left
22:36
kjp joined
22:38
kjp left,
kjp joined
22:47
ulipink joined
22:51
ulipink left
23:19
sena_kun left
23:22
ulipink joined,
ulipink left,
ulipink joined
23:26
ulipink left
23:41
Sgeo joined
|