• Where does this state that it is kernel32.dll?

    From T@21:1/5 to All on Tue Dec 15 22:26:02 2020
    Hi All,

    Windows

    I know from other sources that this call is to a function
    in Kernel32.dll.

    https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/ns-sysinfoapi-memorystatusex

    But where on the page does it state such (kernel32.dll)?
    Am I going blind?

    Many thanks,
    -T

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From R.Wieser@21:1/5 to All on Wed Dec 16 08:31:20 2020
    T,

    But where on the page does it state such (kernel32.dll)?

    It doesn't. You can even search for that 'sysinfoapi.h' file and get
    nowhere either.

    Am I going blind?

    Nope.

    As far as MS is concerned, you do not need to know "trivial" low-level stuff like that. Just install their latest compiler and it will figure out for
    you where all that stuff should be coming from.

    And I wish you luck when you go look for (argument) constants : the names
    and their purposes will be in a table, but you will need to grab their
    actual values from somewhere else.

    (I run in it all the time, as I'm an Assembly programmer.)


    Want an example of their baddness ? Here :

    https://docs.microsoft.com/en-us/windows/win32/api/shlwapi/ne-shlwapi-filetypeattributeflags

    That list is not actually a enumeration but instead bitflags (0x1, 0x2, 0x4, 0x8, 0x10, etc.) *and* it misses some entries - which means that even if
    you know that those constants are bitflags *and* realize that the
    '"FTA_None" will most likely have the value 0x0 (I missed that the first
    time around :-| ) you will get the wrong values for the constants later in
    the list. Like FTA_NoRecentDocs looks, from that list, to have the value 0x00020000, where it actually has the value 0x00100000 (entries for
    0x00004000, 0x00040000 and 0x00080000 are missing).

    You may guess three times how I know the above, and the first two don't
    count. :-)

    tl;dr:
    Become accustomed with being disappointed by the ammount of actual
    information an MSDN page provides.

    Regards,
    Rudy Wieser

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kaz Kylheku@21:1/5 to T@invalid.invalid on Wed Dec 16 10:28:59 2020
    On 2020-12-16, T <T@invalid.invalid> wrote:
    Hi All,

    Windows

    I know from other sources that this call is to a function
    in Kernel32.dll.

    https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/ns-sysinfoapi-memorystatusex

    That's the descritpion of the structure used.

    But where on the page does it state such (kernel32.dll)?
    Am I going blind?

    That's under the associated function:

    https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-globalmemorystatusex

    Past the code sample, under Requirements

    --
    TXR Programming Language: http://nongnu.org/txr

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From T@21:1/5 to Kaz Kylheku on Thu Dec 17 14:48:33 2020
    On 12/16/20 2:28 AM, Kaz Kylheku wrote:
    That's under the associated function:


    https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-globalmemorystatusex

    Past the code sample, under Requirements

    Hi Kaz,

    Ha!

    > DLL Kernel32.dll

    They made that obscure to find. Now I know where
    to look. You'd think they'd put that at the top.

    Thank you!

    -T

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From T@21:1/5 to R.Wieser on Thu Dec 17 14:47:19 2020
    On 12/15/20 11:31 PM, R.Wieser wrote:
    T,

    But where on the page does it state such (kernel32.dll)?

    It doesn't. You can even search for that 'sysinfoapi.h' file and get nowhere either.

    Am I going blind?

    Nope.

    As far as MS is concerned, you do not need to know "trivial" low-level stuff like that. Just install their latest compiler and it will figure out for
    you where all that stuff should be coming from.

    And I wish you luck when you go look for (argument) constants : the names
    and their purposes will be in a table, but you will need to grab their
    actual values from somewhere else.

    (I run in it all the time, as I'm an Assembly programmer.)


    Want an example of their baddness ? Here :

    https://docs.microsoft.com/en-us/windows/win32/api/shlwapi/ne-shlwapi-filetypeattributeflags

    That list is not actually a enumeration but instead bitflags (0x1, 0x2, 0x4, 0x8, 0x10, etc.) *and* it misses some entries - which means that even if
    you know that those constants are bitflags *and* realize that the
    '"FTA_None" will most likely have the value 0x0 (I missed that the first
    time around :-| ) you will get the wrong values for the constants later in the list. Like FTA_NoRecentDocs looks, from that list, to have the value 0x00020000, where it actually has the value 0x00100000 (entries for 0x00004000, 0x00040000 and 0x00080000 are missing).

    You may guess three times how I know the above, and the first two don't count. :-)

    tl;dr:
    Become accustomed with being disappointed by the ammount of actual information an MSDN page provides.

    Regards,
    Rudy Wieser



    Hi Rudy,

    I was not actually trying to use the function. I am trying
    to understand the following tutorial:

    https://raku-advent.blog/2020/12/09/day-11-getting-windows-memory-usage-with-nativecall/

    And where they got "kernel32" from in the following line:

    sub GlobalMemoryStatusEx(MEMORYSTATUSEX) is native('Kernel32') returns
    int32 { * };

    My goal is to under stand methods, classes, and objects in
    Raku. And the Raku documentation is terrible:

    https://docs.raku.org/language/classtut

    And they have the balls to call the page:

    "A tutorial about creating and using classes in Raku"

    When they refuse to define any of their terms starting
    with "what is a 'class'?". You are left to guest from
    context

    I complain a lot of about the sorry state of their
    documentation. Their response on this page was that
    I should already understand that this is Object Oriented
    programming. In other words, if I knew what was going
    on, I would not need their s***ty tutorial.

    So I am trying to write up one for myself. I did
    find this in Perl 5, which ACTUALLY defines what
    things are:

    https://perldoc.perl.org/perlglossary#class https://perldoc.perl.org/perlglossary#object

    So a "class" is a declaration of a custom structure of
    a collection of variables. The name "class" is
    pulled out of someone's ear and you just have to
    live with the obscure meaning they have attached to it.

    And an "object" is when you declare a structure
    using a "class". Object is a little less obscure.
    It is better that "a variable of variables".

    And I am still working on a "method" definition,
    and where they fit into the classes declaration,
    although I use methods extensively

    say (-5..5).rand.truncate.abs**3
    64

    Which means to picks out a random number between -5
    and 5, truncate it into and integer, turn it
    into a positive number, then cube it. Rand,
    truncate, and abs are all methods.

    They can be fun little buggers!

    Thank you for the assist!

    -T

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From R.Wieser@21:1/5 to All on Fri Dec 18 11:18:54 2020
    T,

    First things first: while my complaint about MSDN information still stands,
    I made a mistake when looking at the link you provided : I fully missed it described a structure, not a function (as Kaz made clear). There is some logic to only have it refer to its "parent", the function, just as the
    function refers to its "parent", the DLL.

    And where they got "kernel32" from in the following line:

    sub GlobalMemoryStatusEx(MEMORYSTATUSEX) is native('Kernel32') returns
    int32 { * };

    You're asking where /they/ got their information from ? Thats impossible
    to say ...

    But, if you just want to know which DLL contains a certain function name,
    than, apart from googeling for it, you could extract the function names from all the Windows DLLs[1] and put them into lists for easy searching.

    [1] which, alas, most of them do *not* contain any information about the ammount and types of their arguments.

    And they have the balls to call the page:

    "A tutorial about creating and using classes in Raku"

    Hmmm... I can read that line as "you already know what a class is, here we describe how you use them in the Raku language".

    As far as I can tell there is not much you can know about a class : its a container for methods (functions) and properties (variables), and you can create multiple instances from a single template[2]. The rest
    (implementation) is language dependant.

    [2] In that regard its properties work the same as a function with local variables : each has and manages its own variables (properties). You can
    call such a function multiple times withouth having them mix up their local variables.

    When they refuse to define any of their terms starting
    with "what is a 'class'?". You are left to guest from
    context

    While you are right, think about it : how deep do they need to go ? At
    some point they would end up telling you about the best places to delve
    silica sand to create the wavers from from which the chips are created that make your computer work. Also, what is commonly referred to as "electrical current" does not actually exist. Electrons flow from the negative terminal towards the postive one, not the other way around. :-)

    But granted, I would have been nice of them to mention which knowledge they expect you to already have (so you can go google for it beforehand).

    I did find this in Perl 5, which ACTUALLY defines what
    things are:

    https://perldoc.perl.org/perlglossary#class

    I disagree that that is a good description. They could as well have said
    "see 'data type' "and be done with it.

    Also, a class doesn't need to be "set of possible values, together with all
    the operations that know how to deal with those values". Take for instance
    a class which does a ROT16 operation. It doesn't need any kind of "possible values" (there is nothing it needs to "remember"). Just provide it a string
    as the argument, and the output is the result.

    A class dealing with anything thats not actually stored inside of it but
    acts as an intermediary (from accessing files al the way down to hardware)
    does not (need to) have any "possible values" to act upon either.

    So a "class" is a declaration of a custom structure of
    a collection of variables.

    Nope. That would just be another structure. The difference is that a
    class (normally) also has methods (functions) to work with those variables (properties).

    Also, a class can have *internal* (private) variables[3] that you can only access by way of a method - which means that those internal variables are
    not properties (that you can read from and/or write to).

    [3] Though a language like Python does not offer such "private" variables :
    all of them directly accessible, making them properties.

    The name "class" is pulled out of someone's ear and you just have to live with the obscure meaning they have attached to it.

    Just like any word ? :-)

    My pet peeve ? "Obsolete". It has got two rather different (not even partially overlapping) definitions.

    say (-5..5).rand.truncate.abs**3

    I hope you notice that you are implicitily using a build-in object there
    (there is no class name present), the one dealing with values.

    Also notice that that example mixes together function names with special function symbols ("**") that you most likely won't be able to define for
    your own class(es).

    Which means to picks out a random number between -5 and 5

    Not quite. The "pick a random number" from a provided range is the *second* step. Storing that range into a "variable" is the first. You might be
    able to do different things with that range than just to grab a random value from it.

    Regards,
    Rudy Wieser

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From T@21:1/5 to R.Wieser on Fri Dec 18 14:25:01 2020
    On 12/18/20 2:18 AM, R.Wieser wrote:
    T,

    First things first: while my complaint about MSDN information still stands,
    I made a mistake when looking at the link you provided : I fully missed it described a structure, not a function (as Kaz made clear). There is some logic to only have it refer to its "parent", the function, just as the function refers to its "parent", the DLL.

    And where they got "kernel32" from in the following line:

    sub GlobalMemoryStatusEx(MEMORYSTATUSEX) is native('Kernel32') returns
    int32 { * };

    You're asking where /they/ got their information from ? Thats impossible
    to say ...

    But, if you just want to know which DLL contains a certain function name, than, apart from googeling for it, you could extract the function names from all the Windows DLLs[1] and put them into lists for easy searching.

    [1] which, alas, most of them do *not* contain any information about the ammount and types of their arguments.

    And they have the balls to call the page:

    "A tutorial about creating and using classes in Raku"

    Hmmm... I can read that line as "you already know what a class is, here we describe how you use them in the Raku language".

    As far as I can tell there is not much you can know about a class : its a container for methods (functions) and properties (variables), and you can create multiple instances from a single template[2]. The rest (implementation) is language dependant.

    [2] In that regard its properties work the same as a function with local variables : each has and manages its own variables (properties). You can call such a function multiple times withouth having them mix up their local variables.

    When they refuse to define any of their terms starting
    with "what is a 'class'?". You are left to guest from
    context

    While you are right, think about it : how deep do they need to go ? At
    some point they would end up telling you about the best places to delve silica sand to create the wavers from from which the chips are created that make your computer work. Also, what is commonly referred to as "electrical current" does not actually exist. Electrons flow from the negative terminal towards the postive one, not the other way around. :-)

    But granted, I would have been nice of them to mention which knowledge they expect you to already have (so you can go google for it beforehand).

    I did find this in Perl 5, which ACTUALLY defines what
    things are:

    https://perldoc.perl.org/perlglossary#class

    I disagree that that is a good description. They could as well have said "see 'data type' "and be done with it.

    Also, a class doesn't need to be "set of possible values, together with all the operations that know how to deal with those values". Take for instance a class which does a ROT16 operation. It doesn't need any kind of "possible values" (there is nothing it needs to "remember"). Just provide it a string as the argument, and the output is the result.

    A class dealing with anything thats not actually stored inside of it but
    acts as an intermediary (from accessing files al the way down to hardware) does not (need to) have any "possible values" to act upon either.

    So a "class" is a declaration of a custom structure of
    a collection of variables.

    Nope. That would just be another structure. The difference is that a
    class (normally) also has methods (functions) to work with those variables (properties).

    Also, a class can have *internal* (private) variables[3] that you can only access by way of a method - which means that those internal variables are
    not properties (that you can read from and/or write to).

    [3] Though a language like Python does not offer such "private" variables : all of them directly accessible, making them properties.

    The name "class" is pulled out of someone's ear and you just have to live
    with the obscure meaning they have attached to it.

    Just like any word ? :-)

    My pet peeve ? "Obsolete". It has got two rather different (not even partially overlapping) definitions.

    say (-5..5).rand.truncate.abs**3

    I hope you notice that you are implicitily using a build-in object there (there is no class name present), the one dealing with values.

    Also notice that that example mixes together function names with special function symbols ("**") that you most likely won't be able to define for
    your own class(es).

    Which means to picks out a random number between -5 and 5

    Not quite. The "pick a random number" from a provided range is the *second* step. Storing that range into a "variable" is the first. You might be
    able to do different things with that range than just to grab a random value from it.

    Regards,
    Rudy Wieser



    Hi Rudy,

    Oh good lord you have a gift for teaching. I have
    been asking around and googling my butt off. Your
    explanation was beautiful and the best I have seen.
    I should have asked you first. I am quoting your
    description in my write up.

    Speaking of googling, it does not help that "raku"
    is also a form of pottery.

    I remember a college professor trying to get us to
    think Negative --> Positive, but he gave us as all
    the schematics are written the other way.

    It is not as if I wanted the tutorial to explain
    how OO worked, but a link as to how an explanation
    would have been nice. Your explanation would have
    been perfect too and no extraneous words either.

    And I night point out that the (ha ha) tutorial
    was for Raku, it need to explain how OO was
    implemented into Raku, not leave it to guess work.

    I just discovered that if I want to write to values
    inside an Object, I have to declare the variable inside
    the object as "rw" (read write). They are "ro" (read
    only) by default.

    Thank you!

    -T

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From T@21:1/5 to R.Wieser on Fri Dec 18 14:34:38 2020
    On 12/18/20 2:18 AM, R.Wieser wrote:
    The rest (implementation) is language dependant.

    Did the tutorial forget something? AAAAAAHHHHH !!!!!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From R.Wieser@21:1/5 to Having on Sat Dec 19 10:06:54 2020
    T,

    Oh good lord you have a gift for teaching.

    Thank you. I've been told that I've got a bit of a knack for it. But its
    nice to hear once in a while. :-)

    Speaking of googling, it does not help that "raku" is also a form of
    pottery.

    I know what you mean. And it doesn't help that Google often includes
    "sounds like" and or "is related to" (or something like that) results
    a-plenty (with just a few results that actually contain the asked-for words
    in 10+ pages of crap - with no way to disable it) . :-(

    I remember a college professor trying to get us to
    think Negative --> Positive, but he gave us as all
    the schematics are written the other way.

    Yup. A true "bug with seniority". But, in the end it does not matter
    much for most cases (don't tell that to the electro-plating guys though
    :-) ).

    It is not as if I wanted the tutorial to explain
    how OO worked, but a link as to how an explanation
    would have been nice. Your explanation would have
    been perfect too and no extraneous words either.

    Just keep in mind that I have given a rather terse / basic one. You might still find a thing or two that I have never stumbled over myself.

    And I night point out that the (ha ha) tutorial
    was for Raku, it need to explain how OO was
    implemented into Raku, not leave it to guess work.

    For me one or more annotated examples showing how something is used always works well ("now what happens if I change /this/ into /that ..." *Crash*
    "Oh well, I guess I should not do that than" :-) ). I'm always in awe of people who can just read a chapter outof a book and than know how, in
    theory, something works.

    I just discovered that if I want to write to values
    inside an Object, I have to declare the variable inside
    the object as "rw" (read write). They are "ro" (read
    only) by default.

    I think you need to investigate that a bit further. Although a read-only /property/ sounds like something thats usable, not being able to alter,
    inside the object, the underlying /variable/ doesn't.

    IOW, although its possible that a /property/ can be set to RW, RO or even
    WO, all an objects methods should always be able to read and write the underlaying variable.

    Having said that, I would rather have RW as the default mode for it.

    Thank you!

    You're welcome.

    The rest (implementation) is language dependant.

    Did the tutorial forget something? AAAAAAHHHHH !!!!!

    Honestly ? I wouldn't know.

    But as you have already found, a Raku object can limit access to its
    properties (and thus most likely also has private variables and
    methods(!) ). In Python objects on the other hand nothing is private, /everything/ (properties, variables as well as methods and functions) is accessible from the outside.

    IOW, although both have classes, they work differently.

    Regards,
    Rudy Wieser

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From T@21:1/5 to All on Sat Dec 19 12:47:15 2020
    On 12/19/20 12:42 PM, T wrote:
    BTW, in my write up, I include zillions of examples


    You will love this one. Use your sense of humor reading it:

    class BadMath {
    has Int $.A;
    has Int $.B;

    method BadAdd() {
    my $Clinker = (-5..5).rand.truncate;
    return $!A + $!B + $Clinker;
    }
    }


    The above will get you a "participation trophy" EVERY
    TIME! Well, almost every time.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From T@21:1/5 to R.Wieser on Sat Dec 19 12:42:45 2020
    On 12/19/20 1:06 AM, R.Wieser wrote:
    The rest (implementation) is language dependant.
    Did the tutorial forget something? AAAAAAHHHHH !!!!!
    Honestly ? I wouldn't know.

    NOOOOOOOOO?? Tell me it isn't so!!!!

    :-)

    But as you have already found, a Raku object can limit access to its properties (and thus most likely also has private variables and
    methods(!) ). In Python objects on the other hand nothing is private, /everything/ (properties, variables as well as methods and functions) is accessible from the outside.

    IOW, although both have classes, they work differently.

    Ya, and that is why the (ha ha) tutorial need
    to state such.

    BTW, in my write up, I include zillions of examples

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)