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. |
|||
00:51
sgrs left
03:04
Kaiepi joined
05:53
Heptite left
06:46
ToddAndMargo joined
|
|||
ToddAndMargo | I posted my questions over on pastebin.com/xWr3JTS1 | 06:49 | |
Kaiepi | ToddAndMargo, you'd be in for a read but those are all to do with parameters/signatures. the "Sigil" and "Twigil" sections of docs.raku.org/language/variables, then "Signature literals" in docs.raku.org/type/Signature should cover your bases in that whereabouts | 06:57 | |
ToddAndMargo | Thank you for the links. Is there any chance of answer the specific questions I asked? | 07:00 | |
Kaiepi | describing the parameters would help narrow things down a bit | 07:02 | |
Pointer:D \ptr makes a sigilless positional of type Pointer:D (:D constraining Pointer to an instance) | 07:03 | ||
ToddAndMargo | Line 93 github.com/salortiz/NativeHelpers-...s/Blob.pm6 | ||
Kaiepi | `Int :$elems!` is a required named parameter | ||
`Blob:U :$type` is an optional named parameter that constrains to type objects with :U and defaults to Buf when a value is absent | 07:04 | ||
ToddAndMargo | What does `:D constraining Pointer to an instance)` mean? | 07:05 | |
What does `:` in `:$elems` do? | |||
what does the `!` in `:$elems!` do? | 07:06 | ||
Kaiepi | Pointer considers both a Pointer type object and its instances valid | ||
ToddAndMargo | What do you mean by "instances" | 07:07 | |
Kaiepi | .new makes an instance | ||
ToddAndMargo | what is the "\" doing? | ||
Kaiepi | `\` is marking a sigilless parameter | ||
`:` marks a named parameter | 07:08 | ||
`!` marks a required parameter | |||
ToddAndMargo | ".new"? This is a parameter passed to a sub. What happends to the data being passed if a new instance is being created? | ||
Kaiepi | no new instance is being created, it expects the argument to be one | ||
ToddAndMargo | What is a "sigilless parameter" | ||
what is a "named parameter"? | 07:09 | ||
Oh, if you do not use "!" the user can skip putting something in the value? | 07:11 | ||
Kaiepi | the links explain this stuff in better detail than i could off the top of my head | ||
like with "!" the answer is "depends" | |||
ToddAndMargo | both link are way over my head | 07:14 | |
for instance docs.raku.org/language/variables#S..._variables "Using the \ prefix, it's possible to create variables that do not have a sigil:" than at teh top of teh link, it states: "There are four sigils. The scalar-sigil $, the positional-sigil @, the associative-sigil % and the callable-sigil &.". I use the first three all the | 07:17 | ||
time. Is teh "\" a way of telling Raku "I don't have any idea what this is"? And how does Raku figure it out? | |||
Kaiepi | more or less, yeah | 07:21 | |
i'm not sure on the specifics on how rakudo typechecks those | |||
ToddAndMargo | So Raku gets to figure it depending on what you feed \ptr? | 07:22 | |
Kaiepi | yeah | ||
ToddAndMargo | And the "!". I though yo could only get away with leaving off a parameter on teh last parameter Sum x( Str $a, Str $b, Bool $c= False). What was "!" used on teh center parameter? | 07:24 | |
What should have been why | |||
\ptr is just a 64 bit cardinal (uint64) in this sub. Raku is just going to think it is a cardinal? And not know it is NativeCall Pointer? | 07:26 | ||
"no new instance is being created, it expects the argument to be one" does that mean the variable has only been touched once? | 07:27 | ||
Kaiepi | objects track information pertaining to their type. a Pointer knows its a Pointer, and a Pointer.new knows it's an instance of Pointer and not Pointer itself | 07:32 | |
not sure what you mean by touched, or leaving off the last parameter | 07:33 | ||
ToddAndMargo | Sub x( Str $a, Str $b, Bool $c= False). x("aa","bb") leaves off the last parameter. How is it that you would leave off the middle parameter? | 07:42 | |
instance | |||
ĭn′stəns | |||
noun | |||
An example that is cited to prove or invalidate a contention or illustrate a point. synonym: example. | |||
A case or an occurrence. | |||
A step in a process or series of events. | |||
Kaiepi | you could write `Str $b?` to make it Str when left out, or give it a different default with `=` | 07:43 | |
named parameters imply `?`, while positionals imply `!` | |||
ToddAndMargo | What is Raku's meaning for "instance"? | 07:44 | |
so I could write x("aab", True) and not get the finger wagged at me? | |||
Kaiepi | docs.raku.org/language/glossary#in...y-instance | 07:45 | |
you wouldn't be able to write that, but you could write x("aab") or x("aab", "ccd") or x("aab", "ccd", True) | 07:46 | ||
ToddAndMargo | I am confused. "Str" defines/confines the type of the structure. "=" set a adefault value of the structure. It seems you are using them interchangeably? | ||
docs.raku.org/language/glossary#in...y-instance "An instance of a class is also called an object in some other programming languages" IN Raku, I call (maybe wrongly) a structure created from a OOP class an "object". Is it also called an "instance" | 07:48 | ||
? | |||
Kaiepi | the type serves as the default as well in this case | ||
ToddAndMargo | default structure vs default value? Still confused. | 07:49 | |
Nemokosch | I'm confused about the confusion you seem to create out of thin air 😄 | 07:51 | |
ToddAndMargo | "Str" defines/confines the type of the structure. "=" set as default value of the structure. How is"Str" both? | 07:52 | |
Nemokosch | Let me ask you: if you create a variable `my Str $foo`, what value does $foo have? | 07:56 | |
ToddAndMargo | Still confused about "Blob:U :$type = Buf" "Blob" is the structure. What is the ":U"? "$type" is the variable name and has nothing to do with a particular structure type. NO idea what ":" (marks a named parameter) is. and "Buf" is the default structure? So we are passing a structure not data? | ||
"my Str $foo" is undefined (meaning no data entered) until I put something in it. But the "structure is defined. | 07:58 | ||
Nemokosch | This is a vague answer. What's its value? | 07:59 | |
ToddAndMargo | > my Str $x; say $x; say $x.defined | ||
(Str) | |||
False | |||
Nemokosch | Yes, its *value* is Str | 08:00 | |
ToddAndMargo | So the variable's structure is defined, but is not populated with anything, | ||
confused. $x has no data in it (yet). How is it suddenly populated with the name of its structure? | 08:01 | ||
Nemokosch | It doesn't make conceptual sense that something has no value, not in Raku at least | 08:02 | |
ToddAndMargo | From what I understand of Raku, every variable is a structure with definition of what the structure can do tht is our of the reach of teh programmer. $x's structure states that is is a string and has this and that ability. This, unlike C, where it is an array of characters. | 08:03 | |
"no value" to mean means a fictitious entity called "nil" | 08:04 | ||
The value of $x is nil, not Str | |||
Nemokosch | And that's where you are wrong. Nil does exist but it's not the initial value of... well, anything, as much as I can tell. Maybe the initial value of a subroutine return | 08:06 | |
ToddAndMargo | By "value"I mean the data section of the the Str structure | ||
On 09/12/2018 10:09 AM, Larry Wall wrote: | 08:08 | ||
Basically, ignore any advice to treat Nil as a normal value, because | |||
it really is intended to represent the *absence* of a value as much as | |||
possible. It's a bit like the way solid-state electronics treats "holes" | |||
as if they were real particles, and gets away with it much of the time. | |||
But not all the time, because the hole isn't real; it's the collective | |||
behavior of everything around a thing that's missing. | |||
So while you can test explicitly for Nil if you try hard enough, it's | |||
better not to try at all, because lots of places internally are using | |||
that Nil to select some kind of default behavior that might or might | |||
not look like Nil afterwards. | |||
It was probably a mistake to put Nil into the type hierarchy underneath | |||
the Any type in the first place. It's more of a concept type like | |||
Junction, so probably belongs outside of Any, which sits the top of the | |||
"normal" object hierarchy. | |||
These types are deeply magical. Whenever you find yourself trying to | |||
use Nil or Junction as a normal value, you have to ask yourself whether | |||
you're just Mickey Mouse falling into the Sorcerer's Apprentice trap. | |||
Nemokosch | Don't get me wrong - I feel you in the regard that this design is complicated and conceptually bizarre. But what can we do. Types are all values - default, empty kind of values. | ||
ToddAndMargo | "represent the *absence* of a value" is my sticking point. "Str" would not be the value | 08:09 | |
Still confused about "Blob:U :$type = Buf" "Blob" is the structure. What is the ":U"? "$type" is the variable name and has nothing to do with a particular structure type. NO idea what ":" (marks a named parameter) is. and "Buf" is the default structure? So we are passing a structure not data? | |||
Nemokosch | Bad news for you - Str is a value, moreover it is the default value of an Str-constrained variable or parameter | ||
:U indicates that what we expect has .DEFINITE False - this is more or less synonymous to saying it is a type object | 08:13 | ||
ToddAndMargo | how does a structure type also become a value? | 08:16 | |
Nemokosch | If you say it's bizarre to approach type objects as "indefinite" values of their types (and even mark that with U for confusion), I'm totally with you. But that's how it is so please try to adopt | ||
That's how Raku is designed fundamentally. It doesn't "become" a value, it has always been one | 08:17 | ||
ToddAndMargo | I absolute adore Raku. I am trying to learn what all this stuff mean so I can TAKE ADVANTAGE of it. | 08:18 | |
Nemokosch | I think you need to ponder a bit - "what if types were always values of their own type? What could that mean?" | 08:19 | |
ToddAndMargo | It does make sense to me that say would return the type of structure if the structure's value was nil. "print", on the other hand, tries to print what the structure's value: | 08:21 | |
print "$x\n" | |||
Use of uninitialized value element of type Str in string context. | |||
Methods .^name, .raku, .gist, or .say can be used to stringify it to something meaningful. | |||
in block <unit> at <unknown file> line 1 | |||
Nemokosch | Forget Nil for now. Nil exists outside of the scope of this discourse. | 08:22 | |
ToddAndMargo | "Use of uninitialized value element of type Str in string context." makes total sense to me. But, saying the "value" is "Str" does not. I am obviously missing something/ | ||
Nemokosch | That's why I said - try to make sense of it. What if the value is indeed Str, how do they add up? | 08:24 | |
Could it be that it's Str.gist that produces the error? | |||
08:25
frost joined
|
|||
ToddAndMargo | "You can use the .DEFINITE method to find out if what you have is an instance or a type object: | 08:25 | |
say Int.DEFINITE; # OUTPUT: «False» (type object) | |||
say 426.DEFINITE; # OUTPUT: «True» (instance) " | |||
Is that saying that the value passed is a structure and not data? | |||
Nemokosch | You can actually type Str.gist, by the way. It is valid but it does throw | ||
ToddAndMargo | > Str.gist | 08:26 | |
(Str) | |||
(Map) method gist | |||
Defined as: | |||
method gist(Map:D: --> Str:D) | |||
Returns the string containing the "gist" of the Map, sorts the pairs and lists up to the first 100, appending an ellipsis if the Map has more than 100 pairs. | |||
What the heck is "Returns the string containing the "gist" of the Map" and why did it return the structure type of $x? | 08:27 | ||
What is confusing is how is a structure also a data value? | 08:29 | ||
Nemokosch | Because somebody, probably TimToady, decided this would make sense. That's all there is to it. Technically, it's not that difficult to do | ||
ToddAndMargo | > say $x.chars | 08:31 | |
Use of uninitialized value of type Str in string context. | |||
Methods .^name, .raku, .gist, or .say can be used to stringify it to something meaningful. | |||
in block <unit> at <unknown file> line 1 | |||
0 | |||
[1] > my Str $y = ""; say $y.chars | |||
0 | |||
.chars for $x complains but still answers zero. ("Str" is three characters) | |||
08:31
frost left
|
|||
Nemokosch | Yes because it's not the word Str | 08:33 | |
Have you heard of prototypes? In JS or Lua, for example | 08:34 | ||
ToddAndMargo | no | ||
Nemokosch | Aw, it could come handy | 08:35 | |
You could think of type objects as templates | 08:36 | ||
ToddAndMargo | Oh I see what he is doing. github.com/salortiz/NativeHelpers-...s/Blob.pm6 | 08:37 | |
08:37
razetime joined
|
|||
ToddAndMargo | 93: our sub blob-from-pointer(Pointer:D \ptr, Int :$elems!, Blob:U :$type = Buf) is export { | 08:37 | |
100: my $b = $type; | 08:38 | ||
Very sneaky!!!! Now it all makes sense. | |||
Nemokosch | Btw you can also write (1, 2).new like you can write List.new | 08:39 | |
ToddAndMargo | Did you catch the security booboo on line 94? He should be using memcpy_s instead | 08:40 | |
You guys are extremely patient. Thank you! | |||
"type objects as templates". Is calling them "structures" a C++ thing? | 08:42 | ||
Nemokosch | I think "structure" is a heavily overloaded term | 08:43 | |
You can think of Blob:U as "any Blob type" and the default value is Buf | 08:44 | ||
ToddAndMargo | Oh and the question about defaults on the sub parameter, does that mean I sill have to pass the parameter something and if I pass it something "undefined" then it will use the default? But I still have to pass the middle one something. The end one I can leave off. | 08:45 | |
I am going to be having a lot of fun with this stuff is a week or so. | 08:46 | ||
I am going to tell myself that ":" is a" separator" (a space would cause confusion) and "U" mean undefined. | 08:47 | ||
The more I learn about Raku, the more I am awestruck at the thinking that went into it. | 08:48 | ||
Nemokosch | These `:D` and `:U`things are also called type smileys | 08:49 | |
m: my Str:D $foo is default('bar'); dd $foo | 08:51 | ||
m: my List:D $foo is default(Empty); dd $foo; | 08:52 | ||
08:54
dakkar joined
|
|||
What I wanted to test is 1. If `:D` is about the values rather than how you specify them 2. If it tests .DEFINITE rather than .defined | 08:54 | ||
09:42
Kaiepi left,
ToddAndMargo left
10:36
guifa joined
10:47
Kaiepi joined
12:34
discord-raku-bot left,
discord-raku-bot joined
12:51
razetime left
13:13
sgrs joined
13:28
sgrs left
13:44
sgrs joined
13:53
sgrs left
13:55
razetime joined
15:22
Heptite joined
15:37
bioexpress joined
|
|||
bioexpress | Hi! In a META6.json file: when would I use "zef:myname" and when "github:myname" for the "auth" key - when the prefix "zef" and when the prefix "github"? | 15:46 | |
16:37
Kaiepi left
17:28
razetime left
17:36
discord-raku-bot left,
discord-raku-bot joined
17:42
dakkar left
17:44
Kaiepi joined
|
|||
Kaiepi | i forget if it's fez or raku.land but something or other complains if you try to use `github:` as a prefix with the newer tooling | 17:52 | |
i used to use it | |||
raku.land will complain even if it's on cpan, e.g. raku.land/cpan:KAIEPI/Trait::Traced | 17:54 | ||
but it looks to be valid for p6c repos so that's me being a goof raku.land/github:thundergnat/Timer | 17:57 | ||
Nemokosch | I'd think it's indeed that p6c had no identity whatsoever, besides the github name | 18:00 | |
18:16
deadmarshal left
18:36
deadmarshal joined
18:50
bioexpress left
|