🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). Log available at irclogs.raku.org/raku/live.html . If you're a beginner, you can also check out the #raku-beginner channel!
Set by lizmat on 6 September 2022.
amano How do I poll a queue without removing an item from it? 06:43
Channel doesn't allow me to know whether it is queued at all. 06:44
I want to push something onto a queue only if it is empty.
Or, I want a queue that drops new items if it is not empty already. 06:48
amano Is it safe to share an Array among multiple react blocks? 06:57
amano I want a bounded queue. 07:06
siavash `poll` method returns `Nil` if there is no item in the channel, so `send` an item in an `else` block? 07:10
docs.raku.org/language/concurrency...y_concerns 07:15
amano siavash: I don't understand what you propose. 07:19
siavash `if $channel.poll -> $item { ... } else { # queue is empty, so do what you wanted to do }` 07:42
librasteve stackoverflow.com/questions/437828...en-threads 07:57
^^^ jnthn's answer here is pretty definitive
short version: No
amano siavash: I would like $channel.peek. And, I would also like a bounded queue that has a limited size. 08:04
amano A function that sends a new item to a bounded queue can either wait or drop the new item. 08:40
If the bounded queue is full. 08:41
A bounded queue can be of size 5.
or 1.
hackage.haskell.org/package/stm-2....Queue.html 08:42
hackage.haskell.org/package/brick-...BChan.html 08:43
nemokosch www.reddit.com/r/rakulang/comments...2023_date/ 09:45
amano: raku.land/cpan:JNTHN/Concurrent::Queue maybe this is of interest 09:56
librasteve .oO 09:57
might be a relatively straightforward mini project to fork this and add some bounds... 09:59
amano What is the best IPC mechanism in raku apart from a stream unix socket created by IO::Socket::Async.listen-path? 10:32
amano It seems Supply.throttle may do what I want for implementing bounded queues. 11:29
nemokosch CIAvash is desperately underrated 11:41
amano Are Raku Supplies concurrent or parallel? 11:43
nemokosch I would assume it depends on the scheduler for starters 11:45
docs.raku.org/language/concurrency#Schedulers does this help somewhat? 11:46
ugexe concurrent 11:52
or rather Supply is used for concurrency control 11:53
amano Can Supply.throttle be used for bounded queue? 11:57
Perhaps, I should just get rid of the unix socket while the raku script is processing a message. 11:58
amano I just tested Supply.throttle. It does what I want... 13:06
antononcube @nemokosch Thanks for mentioning CIAvash! I am not sure how that relates to the concurrency discussion -- his "Curry" module? -- but the "PatternMatching", raku.land/zef:CIAvash/PatternMatching, should be very useful for working with LLMs. 14:18
(It seems that "PatternMatching" can be combined very well with "Text::SubParsers".) 14:20
holmdunc I wonder why the 😄 constraint isn't the default in Raku. It seems like most of the time when type annotating function parameters, object instances are what a programmer is thinking about? 17:23
librasteve that's a great question - I personally think that it is useful for a coder to signal "there is no sensible value for this variable yet" rather than be required to load a default (some, any default) of the required type 17:28
(dons hard hat in anticipation of the "raku does not have variables, just containers and value" commentary) 17:29
nemokosch well, there is a "default value" this way as well, except one that might cause trouble if you try to fetch it 17:30
librasteve with :D and :U smileys in eg multi signatures, you can then go a little deeper when you need to make that distinction
m: my Int $x; dd $x; 17:31
Raku eval Int $x = Int
librasteve m: my Int $x; dd $x.WHAT; 17:32
Raku eval Int
librasteve yeah - well I think it is nice that the default value for a typed container is the type object since that carries the type around everywhere whether you loaded an actual value yet 17:33
(or not) 17:47
and I think that this way a signature can check the type of the value and does not care if the argument is initially contained in a typed or untyped container 17:50
m: sub fn( Int $y ) {say $y}; my $x; fn($x); 17:51
Raku eval Exit code: 1 Type check failed in binding to parameter '$y'; expected Int but got Any (Any) in sub fn at main.raku line 1 in block <unit> at main.raku line 1
librasteve m: sub fn( Int $y ) {say $y}; my Int $x; fn($x);
Raku eval (Int) 17:52
librasteve m: sub fn( Int $y ) {say $y}; my $x=Int; fn($x);
Raku eval (Int)
gfldex m: my Int:D $i = 42; $i = Nil; 20:20
camelia Type check failed in assignment to $i; expected Int:D but got Int (Int) (perhaps Nil was assigned to a :D which had no default?)
in block <unit> at <tmp> line 1
gfldex @librasteve Does this ^^^ help to crack that nut? 20:20
Also Raku used to be called Perl 6 and we love our `//`s. 20:21
librasteve m: my Int:D $i = is-default(42); $i = Nil; 20:25
Raku eval Exit code: 1 ===SORRY!=== Error while compiling /home/glot/main.raku Undeclared routine: is-default used at line 1
librasteve m: my Int:D $i = is default(42); $i = Nil;
Raku eval Exit code: 1 ===SORRY!=== Error while compiling /home/glot/main.raku Undeclared routines: default used at line 1 is used at line 1
gfldex Tm: my Int:D $i is default(42); $i = Nil;
m: my Int:D $i is default(42); $i = Nil; 20:26
camelia ( no output )
librasteve ^^ that
gfldex Complexity is the arch-enemy of all programmers. Types can lower complexity but they don't have to. Hence the need for gradual tying. Often &infix:<//> is less hassle then enforcing DEFINITEness. 20:30
m: class undefinedness { method defined { False } }; my $u = undefinedness.new; sub s(Any:D $) { say „huh‽“ } say defined($u); s($u);
camelia ===SORRY!=== Error while compiling <tmp>
Strange text after block (missing semicolon or comma?)
at <tmp>:1
------> dness.new; sub s(Any:D $) { say „huh‽“ }⏏ say defined($u); s($u);
expecting any of:
infix
gfldex m: class undefinedness { method defined { False } }; my $u = undefinedness.new; sub s(Any:D $) { say „huh‽“ }; say defined($u); s($u);
camelia False
huh‽
gfldex The :D type smiley does *not* ask for definedness. 20:31
librasteve (i) I am sure that you are right (trust-wise), (ii) I am sure that you are right (philosophically), (iii) BUT as a "meat and potatoes coder" guy I still cling to the idea of a variable to which a value may be assigned - please humour me/us 20:37
(when I get a tuit I plan to link back up to what I think your saying on my blog) 20:38
meantime - I get that there is .defined (object-wise test that is easy to override) and .DEFINITE (class-wise test that is hard wired) 20:39
gfldex Actually, DEFINITE goes deeper then a class. It exists even before Rakudo learns about classes. 20:41
librasteve being out here in "rakuland" ( as opposed to "NQPland"), please can you point me to the most pithy docs (docs or synapses or blogs is fine) 20:44
gfldex This is not documented. You have to read the source of MoarVM, nqp and Rakudo to understand what is really going on. 20:45
librasteve ok - I see ... that's cool & many thanks!!! 20:47
gfldex If you like to, we can have a little voice chat on Discord. Same handle then here. 20:48
nemokosch the funny thing is that even if you type out .DEFINITE, it's not an actual method call... 20:52
librasteve thanks - I need a couple of days on $day-job will ping when I can 20:57
amano yo 21:47