🦋 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.
grondilu Hi all. Can the gcc builtin be accessed via NativeCall? gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html I tried and failed. 08:46
I tried the very naive : use NativeCall; sub __builtin_clz(uint8 $ --> int8) is native {*} 08:47
and got : ===SORRY!=== Error while compiling Cannot locate symbol '__builtin_clz' in native library '' at line 08:48
dakkar those don't really exist 08:49
they are added (almost certainly as `static`, i.e. not visible to the linker) by the compiler to objects (programs, libraries) that need them 08:50
grondilu I see. So I suppose if I really want to use them I need to write a wrapper library? 08:52
dakkar ah, yes «GCC built-in functions are always expanded inline and thus do not have corresponding entry points and their address cannot be obtained» 08:53
not even `static`, inlined directly
tbf, I'd first ask why you want to access them 08:55
they're either equivalent to libc functions, or very special
(you may have a very good reason, but it's still useful to know it) 08:56
grondilu I'd like to implement www.rosettacode.org/wiki/Posit_numbers but make it as fast as possible. 08:57
dakkar you know where to find an assembler 😜 08:58
wafflus is it a bug if I tell a function to return a int and it returns a Nil and does not crash 08:59
if i return a string it does crash 09:00
dakkar grondilu: also notice that the GCC builtins you were looking at, may change with any gcc release, they're pretty much "internal use only"
wafflus: `int` or `Int`?
wafflus Int
i mean i could tell it to return a Str and it will still work but the signature would be a lie 09:01
dakkar Int is an object type, Nil is a valid value for it
although…
wafflus well that seems silly
dakkar there's… a bunch of reasons, some good 09:02
m: Nil ~~ Int 09:03
camelia ( no output )
wafflus ok i guess i shouldnt question larry
:D
dakkar m: say Nil ~~ Int
camelia False
dakkar m: sub foo(-->Int) { return Nil }; say foo()
camelia Nil
grondilu chatGPT just told me there is no "count leading zero" in libc, but it gave me the equivalent code with bitshift ops. I guess I can write it in raku and it should not be much slower.
dakkar that's the surprising bit, I guess?
wafflus yes
i mean i would kind of expect it to behave the same as when i return a string 09:04
when it was expecting a Int
dakkar grondilu: ① never trust LLMs / Markov chains ② that page you linked already said that ③ "correct" should win over "fast" any day
wafflus also it be cool if it could detect the error when i was creating it as well 09:05
dakkar lizmat: do you happen to know/remember why returning a Nil is allowed even if it doesn't match the return type? I think there's reasons, but I can't remember
wafflus: sorry, you lost me there; when you were creating what? 09:06
lizmat dakkar: initially, Failures were also always allowed to be returned 09:07
when Nil got introduced, it was Nil that is always allowed to be returned
m: sub a(--> Int:D) { Nil }; dd a
camelia Nil
wafflus if you write a function that is obviously incorrect i think raku should not create the function and say the types are incorrect like returning a Str when it should be an Int. instead it just compiles and crashes at run time
lizmat dakkar: at that time, Failure became a subclass of Nil
wafflus some of my terminology may be slightly incorrect
lizmat m: dd Failure.^mro 09:08
camelia (Failure, Nil, Cool, Any, Mu)
lizmat and this Failures are also always allowed to be returned
*thus
dakkar aha! thank you
wafflus: in the general case, what you are asking for is impossible; in many specific cases, it could be implemented (like, the compiler could do a lot of static analysis / data flow / &c and determine that the function could not possibly ever work, and tell you) 09:09
just, nobody got around to it yet 09:10
wafflus i've seen something simlar done in F# but much more complicated
lizmat dakkar: which implies, if you want a class to be always returnable, make it a subclass of Nil:
m: class A is Nil { method raku() { "foo" } }; sub a(--> Int:D) { A }; dd a
camelia foo
dakkar lizmat: that's the kind of cheating we like in the Perl family, but that we never want to see in Real Code™ 😁 09:11
btw, is there any way to mark a function as "no, I'll never return a Failure/Nil"?
lizmat create a subset with a constraint that will die if given a Nil ? 09:12
and then --> thatconstraint ?
dakkar m: sub foo(-->Int:D) { return Nil }; say foo()
camelia Nil
dakkar ehrm 09:13
also, I asked my question badly… what I really meant is: would it make sense to have a way to tell _the compiler_ that we intend this function to never return a Failure/Nil, so that future implementations may exploit that fact? 09:15
lizmat meh, that idea doesn't fly, as the constraint check is simply bypassed for Nil apparently
grondilu If I want the two-complement of an unsigned int, can I just negate it? say -my uint8 $ = 1
dakkar grondilu: I feel you're confusing values and representations 09:16
grondilu that is likely
lizmat dakkar: that makes sense
dakkar grondilu: if you want the complement of a *string of bits*, you operate on the bits; if you want the negative value of a number, you negate it… 09:17
grondilu what about my uint8 $ = -my int8 $ = my uint8 $ = 1 ? 09:18
dakkar grondilu: if you want to see the representation of a number as a string of bits… you have to dig in the innards of whatever implementation you're using (and sometimes this digging ends below the asm level)
wafflus i tried to do a !Nil no luck
dakkar wafflus: yes, that's what we've just noticed, you can always return Nil from a function (unless it returns a native, non-boxed type, but those are a different beast)
m: sub foo(-->int) { return Nil }; say foo()
camelia Cannot unbox a type object (Nil) to int.
in sub foo at <tmp> line 1
in block <unit> at <tmp> line 1
grondilu dakkar: that can't possibly be that complicated, can it? 09:19
lizmat heh... that feels like a bug
dakkar lizmat: the unbox, or that you can return Nil from a sub marked `-->Int:D`?
lizmat the unbox
dakkar grondilu: depends! if you want a twos-complement representation, you "just" write your own representation code; if you want to see how the language+runtime+computer actually represents things… that may be very complicated 09:20
lizmat: `int` can't represent an undefined value, so (apart from maybe a LTA error message), the behaviour feels correct to me 09:21
wafflus thinks it silly to have two things with the same name (int or int) to confuse people 09:23
dakkar wafflus: the naming is sub-optimal, yes; the fact that we have both is actually pretty important 09:24
values of type `Int` are objects: they have methods, you can subclass them, apply traits, &c&c 09:25
values of type `int` are raw numbers: you can only do some arithmetic with them, but they take less space in memory and are a bit faster
wafflus k cool 09:26
dakkar (other languages have the same distinction, often with the same sub-optimal naming, e.g. Java docs.oracle.com/javase/tutorial/ja...types.html ) 09:27
wafflus int also initilizes a value
and makes it defined
 ofc but we learn form our mistakes hopefully
dakkar more or less. more precisely: values of type `int` cannot be undefined, and have a default value of `0`
wafflus maybe the shold have called it a qint  for a quick int :) 09:29
nemokosch I opened an issue for "Failure is Nil" once upon 09:58
it wasn't well received tbh
> that's the kind of cheating we like in the Perl family, but that we never want to see in Real Code™ 😁 that's very much on point...
int is basically a VM-level integer, practically the same thing as C's int 09:59
guifa o/ 10:30
lizmat And yet another Rakudo Weekly News hits the Net: rakudoweekly.blog/2023/09/18/2023-...ew-search/ 10:42
nemokosch lizmat++ spreading the word about the new search is the best thing we can do for UX at the moment 10:44
wafflus a suggestion for the manual when you search sometime it comes up with multiple version of the same keyword. it would be nice if you could tell the difference between the two before you click on the page 11:02
for example search for do and you will get two do's 11:03
nemokosch have you seen new-raku.finanalyst.org/ ? 11:05
wafflus nope
looks interesting and better 11:06
however
not sure when i search for do i think it maybe should list the do first 11:07
and not about docs
but those at the bottom
put
lizmat please report your findings at github.com/Raku/doc-website/issues/new/choose :-) 11:09
nemokosch yeah fair enough 11:10
wafflus lizmat is that an issue or a complaint though? 11:12
lizmat it's a comment? 11:13
at this point, any comment / suggestion / complaint / issue is welcome to get more feedback
wafflus does not have a github account atm
lizmat ah... hmmm.... 11:14
is it a problem for you to get one ?
wafflus i can get one i just don't like using my real emails 11:15
or i had one and i forgot the email 11:16
i guess thats strange these days 11:17
that one of the reason i use IRC
nemokosch not many reasons remain for using IRC these days, that's for sure... 11:19
even XMPP is kinda retro and it's rocket science compared to IRC
wafflus i'm also kind of private and maybe paranoid about it 11:20
nemokosch Okay, now a bit of English 11:22
wafflus plus alot of these online forms are a little mod heavy
nemokosch because I'm not sure if English is at fault or the user in this case...
so what does it mean if I say
"any of these numbers is greater than 5"
to me this would mean all of them 11:23
wafflus to me it would be any or all 11:24
nemokosch okay but what does it mean with "any",
?
wafflus i guess 11:25
what if
you go throught each person and you ask if any of them want to reaise there hand from the perspective of each person they would all be any
if that makes sense
nemokosch I get that 11:26
wafflus but maybe your is more correct english wize
wafflus you are more correct 11:26
nemokosch that would mean "is there a person P for which P wants to raise their hand"
but I feel that there is a difference of meaning with a statement 11:27
"is any of these numbers greater than 5" clearly means "is there a number X among these numbers for which X > 5" 11:27
El_Che wafflus: use rotating burner emails? 11:28
nemokosch it seems to me that the statement doesn't have the same meaning
wafflus El_Che ok
:person A to group b would anyone like to eat dinner 11:29
wafflus all could raise there hands or 1 or some 11:29
or none ofc 11:30
nemokosch "any" seems too fragile
"any of you can drive a car"
this quite clearly means "all of you" 11:31
"any of you are adults" - now, this just sounds stupid I think
wafflus i agree with that last one lol 11:32
you are probally right we need a better word
nemokosch or take this one 11:33
"not anyone can do that"
this doesn't mean downright "nobody can do that"
much rather just "not all people can do that" 11:34
wafflus it is kind of confusing for noobs like myself 11:38
nemokosch as we have come this far, I don't think we can do much about it but I think it's worth thinking about and be aware of 12:04
if we are using terms like "true" and "false", we are clearly thinking in statements, not questions 12:05
it's not terribly useful to use a word like "any" as a term, then, which has its "true meaning" in questions
guifa "any of you X" is the same as "all X, but has a connotation 13:36
err
tea3po I mean there's lots of this stuff in english that you run into in logic, around words like "any" and "only" 13:37
[Coke] nemokosch: I did not end up getting time to work on zef-deps, still in my queue though
guifa "any of X" is the same as "all X" but has a potentiality connotation (hence it's often used with might/would/could)
nemokosch I think on a meta level "any" is like "the listener will fill this word in" 13:38
so when it appears in a question, it's like "can you fill it in so that we want to make it a true statement?" 13:39
but when it appears in a statement (often a speculative statement), it expresses a great load of confidence
"no matter how you fill it in, the statement will still be true" 13:40
thundergnat While I don't disagree that in English, "any" can have a murky meaning in a statement, in Raku, "any" means "at least one". Try substituting "at least one" into all of the above sentences and they're much less ambiguous. The problem is that English doesn't really have a better (short) word for "at least one".... and I,for one, would much rather 14:25
type any(..) than at-least-one(...).
Maybe some other language has a better word for the concept that could be appropriated. Can't readily think of one but I am not multi-lingual. 14:26
tbrowder__ hi, i just released File::Copy and i would appreciate any feedback. 14:30
nemokosch I think "some" itself is much better than "any", for what it's worth 14:32
moreover, "any" led to the temptation to special-case negation for Junctions, which I think nobody actually likes
any(a, b) != c turning into none(a, b) == c for the lolz 14:34
tbrowder: github.com/raku-community-modules/...nd/pull/43 if you feel up to it 14:35
I see we got yet another HTML escaper as well... 14:37
is it mi6 that generates these "perl": "6.*" versions? 14:38
tbrowder__ could be. 15:08
have we agreed what it should be? 15:09
tbrowder__ nemokosch: “feel up to it” you mean “merge” or fix something on the PR? 15:45
nemokosch well, I see that somebody added a couple of comments... 15:57
that may have been me but anyway 😛
tbrowder__ i’ll see if i can fix the badges for one thing 16:55
[Coke] released 0.9.8 of zef-deps which tracks the latest change in zef not to be explicit about a version 17:20
(in the case of nativecall & test)
tonyo ? 18:25
[Coke] it used to say nativecall:ver<6.c+> or similar, now it just says Nativecall 18:26
tonyo ahh, less to do about how zef resolves :from<native>
[Coke] you can see the test output changes (and dependency changes) here: github.com/coke/raku-zef-deps/comm...42941ca5a9
tbrowder__ nemokosch: what is ye 19:13
*yr github handle?
or "ye" for olde
*oldish english 19:14
nemokosch Just look at the PR ^^ 19:15
tonyo it means they when "they" are the subject, most generally 19:19
tea3po y is a substitute for letter thorn which is a ligature of t and h 19:25
en.wikipedia.org/wiki/English_articles#Ye_form
nemokosch Coke: is there something like zef-deps but for reverse dependencies? 20:33
took some time until I realized that it's what I actually need now; basically I want to check the impact of a certain distribution 20:34