🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). This channel is logged for the purpose of keeping a history about its development | evalbot usage: 'm: say 3;' or /msg camelia m: ... | Logs can be inspected at colabti.org/irclogger/irclogger_log/raku
Set by lizmat on 1 May 2021.
Geth doc: 9ef2ef0046 | (JJ Merelo)++ | doc/Language/variables.pod6
Removing references to "interpolation"

Slightly rewording and explaining what a twigil is, too. Following @treyharris pointed advice on the thoughts on the original test. Closes #2588
08:47
linkable6 Link: docs.raku.org/language/variables
Geth doc: d685762903 | (JJ Merelo)++ | 2 files
Splits the "environment variables" file in two parts

The original file no longer reflected its intent, so it's better to have it split. It also helps with making information on running raku more prominent, following #2263
10:18
doc: 185de4d168 | (JJ Merelo)++ | doc/Programs/04-running-raku.pod6
Changes text to current raku -h text

Which includes a good amount of stuff...
doc: 530d05ed56 | (JJ Merelo)++ | doc/Programs/04-running-raku.pod6
Some clarifications #2263

It remains to check if those target options still remain.
whatnext hello all:)  quick question: I understand that executing a method stored in a variable can be done via `$object."$variable"()` - but what about a meta method? Neither `$object."^$variable"()` or `$object.^"variable"()` seem to work? 12:33
codesections there might be a shorter way, but this is what comes to mind: 12:38
m: my $meth = 'methods'; say 42.HOW."$meth"(42)
camelia (new Capture Int sign Num Rat FatRat abs Bridge sqrt base polymod expmod is-prime floor ceiling round lsb msb narrow Range conj rand sin asin cos acos tan atan atan2 sec asec cosec acosec cotan acotan sinh asinh cosh acosh tanh atanh sech asech cosech…
codesections (42.^methods is just sugar for 42.HOW.methods(42)) 12:39
whatnext ah yes ok I get it - thanks I will try that 12:40
ecocode[m]1 is HOW an acronym ? 13:16
codesections Yeah, for Higher Order Workings (I wasn't around, but I suspect they really wanted it to spell HOW, because that doesn't mean a whole lot...) 13:18
tobs it also ties into WHO, WHICH, WHAT and WHY, other ALLCAPS introspection methods 13:26
and WHERE 13:27
ecocode[m]1 thx ! 13:58
xinming is there a json kind of file format which has richer types but cross platform please? 15:00
ugexe xml?
codesections TOML and YAML are also frequently suggested 15:01
Geth doc: ea511b1702 | (Stoned Elipot)++ | doc/Language/nativetypes.pod6
Use code formatting
15:14
linkable6 Link: docs.raku.org/language/nativetypes
ecocode[m]1 < matrix.org/_matrix/media/r0/downlo...essage.txt > 15:18
xinming ugexe: xml feels too lengthy 15:19
I'll check TOML, I don't like yml
ecocode[m]1 < matrix.org/_matrix/media/r0/downlo...essage.txt > 15:20
tbrowder howdy! 16:46
pray tell what is the unicode hex value for the tiny newline char as is desired in a pod doc OUTPUT: line? 16:48
lizmat m: say "foo" 16:50
camelia foo
lizmat m: say "␤".ord
camelia 10
lizmat m: say "␤".uniname
camelia <control-000A>
lizmat hmmmm
some weird interaction there, locally: 16:51
$ r 'say "␤".ord.base(16)'
2424
$ r 'say "␤".uniname' 16:52
SYMBOL FOR NEWLINE
tbrowder the two enclosing guillemot codes are xaa and xbb 16:53
i can use the uniname, thanks, lizmat 16:54
lizmat m: say "\x2424" 16:55
camelia
ecocode[m]1 < matrix.org/_matrix/media/r0/downlo...essage.txt > 17:00
tbrowder m: say "\c[symbol for newline]" 17:02
camelia
tbrowder m: say "\c[newline]" 17:03
camelia 5===SORRY!5=== Error while compiling <tmp>
Unrecognized character name [newline]
at <tmp>:1
------> 3say "\c[newline7⏏5]"
lizmat ecocode[m]1 not sure how to interpret the gist: if it is a question, why not just asked ? 17:07
ecocode[m]1 lizmat: there is a question 😉 "How do I send a pointer to an int32 raku var to a C-function ? " 17:09
but it is probably bad formulated
* but it is probably badly formulated
lizmat isn't this just about setting up the right signature for the "is native" sub? 17:10
tbrowder m: say "OUTPUT: \xabsome string\x2424\bb"
camelia OUTPUT: «some string
b
tbrowder m: print "\xabsome string\x2424\xbb" 17:11
camelia «some string
»
ecocode[m]1 ```
sub cfunc ( int32 is rw ) returns int32 is native('mylib') {*};
```
but does not work 17:12
or maybe it does, but I can't figure how to send take a Pointer to my ```int32 $var``` when I call the sub 17:13
* or maybe it does, but I can't figure how to take a Pointer to my `int32 $var` when I call the sub
lizmat from this code I cannot draw any conclusion on what could be wrong 17:14
need some code that shows a wrong answer and what you expect it to be
ecocode[m]1 hmmm 17:15
I'm trying to call a function from the lpsolve lib
I can send you the code I am trying out, but you'd need to install the lib on your system ... 17:16
and I don't want you to bloat your system for me 17:17
lizmat please make a gist of the code 17:18
is that lib apt-gettable ? 17:19
ecocode[m]1 glot.io/snippets/fynuds3xgg 17:20
<lizmat "is that lib apt-gettable ?"> I guess so... it should be called lpsolve
lizmat E: Unable to locate package lpsolve # meh 17:21
ecocode[m]1 > <@freenode_lizmat:matrix.org> is that lib apt-gettable ?
* I guess so... it should be called lp-solve
lizmat echo!
ecocode[m]1 corrected: lp-solve
```my $pv_row = nativecast(Pointer[num64],$v_row);``` 17:24
is just one of the many trials I did...
I did not expect it function
lizmat Cannot locate native library 'liblp-solve55.so' # meh 17:27
it *is* there
ecocode[m]1 hmprf 17:30
lizmat Native call cast expected return type with CPointer, CStruct, CArray, or VMArray representation, but got a P6opaque (Num)
does that sound familiar ?
ecocode[m]1 yup
at least with the code I pushed ... 17:31
still trying out a lot of stuff
no success though
I can't seem to get a Pointer to the num64 $v_row 17:33
and nativecall is very opaque to me (if that is what I need)
lizmat ecocode[m]1: I don't see immediately what is wrong, I hope someone else will pick this up 17:36
ecocode[m]1 Ok. Thanks for looking into this ! 17:38
lizmat ecocode[m]1 just too deep into other stuff atm, sorry
in any case, looks like debian has the lp-solve library installed by default, so there no problem wrt bloating systems 17:39
ecocode[m]1: fwiw, I'm working on a better way to look at the IRC logs: 17:46
logs.liz.nl/raku/search.html # alpha version
ecocode[m]1 awesome ! 17:50
El_Che hi ecocode[m]1 18:03
raydiak ecocode[m]1: add_constraintex is expecting arrays, not just pointers to single values. something more like "sub add_constraintex( LPrec, int32, CArray[num64], CArray[int32], int32, num64)" is probably closer 18:04
ecocode[m]1 <raydiak "ecocode: add_constraintex is exp"> I'll try that out 18:21
raydiak here is one working example: gist.github.com/raydiak/4b41408ebf...ba54f23c4f 18:37
not saying it's the best way to do it, I'm no expert with nativecall and typed arrays and all that, but hopefully it's a starting point for learning 18:40
ecocode[m]1 thx ! 18:41
raydiak you're welcome :)
ecocode[m]1 I had this glot.io/snippets/fynwl27pky , but that gave an error... 18:42
I compare with yours 😀
raydiak also notice you can't have a space between "sub" and "(arg, arg, ...)". you can either do "sub arg, arg, ..." or "sub(arg, arg, ...)". it treats "sub (arg, arg, ...)" as passing a single list instead of multiple arguments to the sub 18:44
ecocode[m]1 excellent ! that space solved the issue !!!! 18:46
raydiak just for future reference, telling us what error you're getting can be very useful instead of just "an error" :) 18:47
ecocode[m]1 now that is weird though
is that only for NativeCall subs ? or also for normal methods ? 18:48
raydiak all subs
ecocode[m]1 yup, figured that 😀 18:48
it still feels weird ;) 18:49
raydiak it thinks "sub (arg1, arg2, ...)" is the "sub arg1, arg2, ..." form because of the space, so it treats the "(arg1, arg2, ...)" as a List being passed all into the first parameter
ecocode[m]1 because you define methods with a space after the subname and you can't when you call it 18:50
yup, I understand the idea..
raydiak you can define subs/methods without the space if it makes you feel better :) 18:51
ecocode[m]1 maybe it is good practice to never add a space between subname and (
lizmat that's what I prefer, but people like Tux disagree :-) 18:52
but then, they have a slang all to their own :-)
ecocode[m]1 so you do ```subname( arg1, arg2 )``` 18:53
?
or you just remove all the spaces ?
raydiak I don't, but you can :)
I tend to just not use the () unless I have to
ecocode[m]1 hmmm 18:54
when do you "have to" ?
raydiak my definitions usually look like "sub subname ($param1, $param2) {" and call like "subname $arg1, $arg2;" 18:55
ecocode[m]1 I'd love to have a rakutidy for this 😀
raydiak if there's something else after the sub call you need the parens. e.g. "get_something($with, $args).do_something_else_with_it" 18:56
ecocode[m]1 ah ok
raydiak or if it's in a list like "(sub1($arg), sub2($arg))" 18:57
because (sub1 $arg, sub2 $arg) parses as (sub1($arg, sub2($arg))) 18:58
I think
anywhere it seems ambiguous I just add the parens to make sure 18:59
ecocode[m]1 yup, I'll follow the footsteps of lizmat 😀 19:00
well, now that the code seems to work, it looks pretty clean 🤓
raydiak she is an excellent example to follow, very clean and clear code from what I've seen. better than my own, for sure
raydiak m: sub f (Num() @a) { dd @a }; f [1] 21:37
camelia Type check failed in binding to parameter '@a'; expected Positional[Num(Any)] but got Array ([1])
in sub f at <tmp> line 1
in block <unit> at <tmp> line 1
raydiak this is something I never quite learned...I get that it isn't accepting it because the type of the passed array doesn't match the type of the parameter, but how *do* I get it to accept a plain untyped list of whatever and coerce it to an array of e.g. Num in this example?
codesections m: sub f (Array[Num()]() $a) { dd $a}; say f [1] 21:39
camelia Array[Num(Any)].new(1e0)
Nil
codesections I don't know how to do so with an @ sigil, though 21:40
raydiak thanks! can I do that with an @-sigiled parameter?
ah, you beat me :)
codesections yeah, it _seems_ like there should be a way..., but I haven't found it 21:41
tonyo m: sub f (Num() @a) { dd @a; }; my Int @b = 1,2,3; f @b 21:42
camelia Array[Int] @b = Array[Int].new(1, 2, 3)
tonyo hmm
m: say Int ~~ Num(); 21:44
camelia True
codesections m: sub f (Array[Num()]() $a, @a = $a) { dd @a}; say f [1] # Not sure if this counts :D 21:45
camelia Array[Num(Any)].new(1e0)
Nil
raydiak heh...I'd be more inclined to put that in the body than the sig 21:50
codesections yeah, agreed, … but that _clearly_ wouldn't be creating an @-sigiled param, where as this kind of is 21:52
or, is, but at too high a cost
raydiak are you lawyering me? ;) 22:02
tonyo m: sub f (@a where { $_.map: *.=Num }) { dd @a[0]; }; f( [1,2,3] ); f([qw<a b c>]) 22:04
camelia Num element = 1e0
Failure element = Failure.new(exception => X::Str::Numeric.new(source => "a", pos => 0, reason => "base-10 number must begin with valid digits or '.'"), backtrace => Backtrace.new)
tonyo that works too but is just as ugly
codesections re lawyering 22:05
:D
tonyo: I _think_ that has different semantics -- doesn't that always do a run-time check, whereas Array[Num()]() is at least theoretically compile-time? 22:06
tonyo yea that's always runtime 22:07
the coercion has to be runtime too 22:14
fwiw.
codesections fair point. Well, if we have to drop to runtime, then this is also an option 22:17
m: sub f (@a where all .map: * ~~ :Num | 0) { dd @a }; say f [1]; say f [1, 0]; f <a b c> 22:18
camelia Array element = [1]
Nil
Nil
Array element = [1, 0]
Constraint type check failed in binding to parameter '@a'; expected anonymous constraint to be met but got List (("a", "b", "c"))
in sub f at <tmp> line 1
in block <unit> at <tmp> line…
codesections (it'd actually be fairly pretty but for that 0 edge case ...) 22:19
tonyo i guess it could be compile if everything was typed, eg eating json from a webservice into a predefined structure 22:30
thundergnat m: sub f (*@a where {.=map: *.Num}) { dd @a; }; f 0, 1e0, 3, 1.19, e; 23:01
camelia Array element = [0e0, 1e0, 3e0, 1.19e0, 2.718281828459045e0]
tonyo m: sub f (*@a where {.=map: *.Num}) { dd @a; }; f 'a', 'b'; 23:05
camelia Array element = [Failure.new(exception => X::Str::Numeric.new(source => "a", pos => 0, reason => "base-10 number must begin with valid digits or '.'"), backtrace => Backtrace.new), Failure.new(exception => X::Str::Numeric.new(source => "b", pos => 0, …
tonyo m: sub f (*@a where {all .=map: *.Num}) { dd @a; }; f 'a', 'b'; 23:10
camelia Constraint type check failed in binding to parameter '@a'; expected anonymous constraint to be met but got Array ([&CORE::infix:<orels...)
in sub f at <tmp> line 1
in block <unit> at <tmp> line 1
tonyo m: sub f (*@a where {all .=map: *.Num}) { dd @a; }; f 3, 4;
camelia Array element = [3e0, 4e0]
thundergnat m: sub f (*@a where {.=map({$_ ~~ Numeric ?? .Num !! Num}) }) { dd @a; }; f 0, 1e0, 3, 1.19, e, 'a'; 23:52
camelia Array element = [0e0, 1e0, 3e0, 1.19e0, 2.718281828459045e0, Num]
moon-child m: say 5i ~~ Numeric; say 5i.Num 23:57
camelia True
Cannot convert 0+5i to Num: imaginary part not zero
in block <unit> at <tmp> line 1
japhb s/Numeric/Real/