• UID: Generating pointers in awk

    From digi_cs@cosmogen@gmail.com to comp.lang.awk on Fri Oct 11 18:35:11 2024
    From Newsgroup: comp.lang.awk

    Hello Everybody

    For those who write long programs in AWK, pointers and working with strong values are essential.

    I would like to introduce to my small project - a compact user-level awk library designed for generating "unique" strings that is may be used as the abstract pointers in awk.

    The library contains (I hope) good documentation

    In my opinion, this library is key for the further development of programming in awk as a whole. It provides users with pointers.

    In the documentation, I tried not only to describe the programming interface but also to briefly demonstrate the main techniques for using pointers in awk.

    Link to the project: https://github.com/digics/UID10

    I would really appreciate hearing any feedback, comments, and evaluations of my work. This applies to both the code itself and the documentation.

    Best regards,
    Denis


    --------------= Posted using GrabIt =----------------
    ------= Binary Usenet downloading made easy =---------
    -= Get GrabIt for free from https://www.shemes.com/ =-

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Janis Papanagnou@janis_papanagnou+ng@hotmail.com to comp.lang.awk on Fri Oct 11 18:07:27 2024
    From Newsgroup: comp.lang.awk

    On 11.10.2024 17:35, digi_cs wrote:
    Hello Everybody

    For those who write long programs in AWK, pointers and working with
    strong values are essential.

    What do you mean by "strong values"?


    I would like to introduce to my small project - a compact user-level
    awk library designed for generating "unique" strings that is may be
    used as the abstract pointers in awk.

    Do you (maybe) mean "references"? Or really "pointers" as we know them
    from C or C++?


    The library contains (I hope) good documentation

    In my opinion, this library is key for the further development of
    programming in awk as a whole. It provides users with pointers.

    In the documentation, I tried not only to describe the programming
    interface but also to briefly demonstrate the main techniques for
    using pointers in awk.

    Link to the project: https://github.com/digics/UID10

    I would really appreciate hearing any feedback, comments, and
    evaluations of my work. This applies to both the code itself and the documentation.

    A quick general comment...

    Awk is a HLL, abstracting from low-level constructs. It's beyond me
    why you think that pointers would be necessary or even "key for the
    further development of programming in awk as a whole".

    I might say more if I'll have read the documentation.

    BTW; I would have appreciated it if you'd have provided some minimum
    more concrete information here in this newsgroup about the features,
    rationale, and similar useful information, before directing us to
    external Web-links to github trees.

    Janis


    Best regards, Denis


    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From digi_cs@cosmogen@gmail.com to comp.lang.awk on Fri Oct 11 23:26:45 2024
    From Newsgroup: comp.lang.awk



    Janis: What do you mean by "strong values"?

    See documentation: hid





    Janis: Do you (maybe) mean "references"? Or really "pointers" as we know them from C or C++?

    I mean true pointers – but not at this level yet.

    A pointer — being a short special string — can reference as many arrays and strings as you want:

    FIELD[ ptr ] FIELD2[ ptr ] FIELD3[ ptr ] ...
    By passing the pointer string, you’re passing an "object" — not a string, not an array, but a collection of them.
    Let me give you the simplest example:
    For sequential parsing of a string, we need to store the original string somewhere and associate it with the index of the current character from which the next search (match) will take place. The question is: how do you link two independent values? Through a pointer:
    Let’s assume the original string is stored in _MAC[ ptr ] and the index of the current character in the string is stored in _MACSP[ ptr ]. By passing ptr, you’re passing both of these values. Now imagine how many different fields an object can have — and all of this is passed by a short pointer string.
    A pointer can be assigned to a variable and returned as a function result. Pointers can be combined and passed together as a list.
    To understand this better, check the library’s code — how the UID generators are implemented is an excellent example of how to work with pointers.


    Janis

    A quick general comment...

    Awk is a HLL, abstracting from low-level constructs. It's beyond me
    why you think that pointers would be necessary or even "key for the
    further development of programming in awk as a whole".

    I might say more if I'll have read the documentation.

    ??? ?????? ??, ? ??? ? ? ?????? — ?????? ??????? ???????????. ?????? ?? ????? ??????????? «?????????» ? ?? ?????? ???????? ??? ?????????


    Janis:

    BTW; I would have appreciated it if you'd have provided some minimum
    more concrete information here in this newsgroup about the features,
    rationale, and similar useful information, before directing us to
    external Web-links to github trees.

    The difficulty lies in the fact that the unique strings generated by this library are not fully-fledged pointers. Such pointers only appear with the class-based implementation, which I also plan to release. Yes, you can use the strings generated by the default UID generator as pointers, but they are merely abstract strings — which, for example, can be placed directly into the original data if, say, it’s text.
    Therefore, the description of basic pointer manipulation techniques is a task for the future class-based implementation. This library only provides the bodies of the pointers. Nevertheless, they CAN be used effectively in awk.




    --------------= Posted using GrabIt =----------------
    ------= Binary Usenet downloading made easy =---------
    -= Get GrabIt for free from https://www.shemes.com/ =-

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From digi_cs@cosmogen@gmail.com to comp.lang.awk on Fri Oct 11 23:39:46 2024
    From Newsgroup: comp.lang.awk

    Janis

    A quick general comment...

    Awk is a HLL, abstracting from low-level constructs. It's beyond me
    why you think that pointers would be necessary or even "key for the
    further development of programming in awk as a whole".

    I might say more if I'll have read the documentation.

    That's exactly what I'm talking about — a higher level of constructs. Now we can work with "objects" and not just strings or arrays.


    --------------= Posted using GrabIt =----------------
    ------= Binary Usenet downloading made easy =---------
    -= Get GrabIt for free from https://www.shemes.com/ =-

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Ed Morton@mortonspam@gmail.com to comp.lang.awk on Sun Oct 13 11:51:00 2024
    From Newsgroup: comp.lang.awk

    On 10/11/2024 10:35 AM, digi_cs wrote:
    Hello Everybody

    For those who write long programs in AWK, pointers and working with strong values are essential.

    Enough long programs have been written in awk over the past 40 years or
    so to make that statement clearly not true.


    I would like to introduce to my small project - a compact user-level awk library designed for generating "unique" strings that is may be used as the abstract pointers in awk.

    Please post a minimal, complete example of how your library would be
    used to solve a problem. Show an awk script with vs without your
    library, for example. Don't expect people to have to go clicking around reading external sites to understand your post.

    Ed.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Janis Papanagnou@janis_papanagnou+ng@hotmail.com to comp.lang.awk on Sun Oct 13 19:00:29 2024
    From Newsgroup: comp.lang.awk

    On 11.10.2024 22:26, digi_cs wrote:
    Janis: What do you mean by "strong values"?

    See documentation: hid

    This answer makes no sense, and it explains nothing.

    If you introduce arbitrary terms (here the attribute "strong"),
    and have not even enclosed the whole term in quotes (as I did)
    to indicate that you want to express some specific own concept,
    you should at least explain (here in your post) what you mean.

    Also, instead of issuing yet another new posts in a new threads
    please followup in your original thread to my post for a reply
    to my question so that I can see if and when you answered. That
    makes it also easier to ignore threads completely. That's what
    threads in Usenet are for.

    Janis

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Kaz Kylheku@643-408-1753@kylheku.com to comp.lang.awk on Sun Oct 13 18:19:47 2024
    From Newsgroup: comp.lang.awk

    On 2024-10-13, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
    On 11.10.2024 22:26, digi_cs wrote:
    Janis: What do you mean by "strong values"?

    See documentation: hid

    This answer makes no sense, and it explains nothing.

    I suspect "strong value" might be a superfluous synonym for "object".

    I.e. something that keeps its identity and state as you pass
    it around anywhere you like. It's strong because its pieces stay
    together, accessible through the same handle.

    In Awk, you can't pass aggregate values around other than strings.

    You can pass associative arrays down into functions, but not
    return them, or assign them from one variable to another.

    If arrays could be returned and assigned, they could be used to simulate objects with fields, like the way dicts are used in JS. (Which is not
    great, but better than hacks like indices into global arrays to simulate pointers.)
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Janis Papanagnou@janis_papanagnou+ng@hotmail.com to comp.lang.awk on Sun Oct 13 20:55:49 2024
    From Newsgroup: comp.lang.awk

    On 13.10.2024 20:19, Kaz Kylheku wrote:
    On 2024-10-13, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
    On 11.10.2024 22:26, digi_cs wrote:
    Janis: What do you mean by "strong values"?

    See documentation: hid

    This answer makes no sense, and it explains nothing.

    I suspect "strong value" might be a superfluous synonym for "object".

    I wouldn't have associated that term with "object orientation" or
    some such. - I assume you have read his github docs?

    [ snip elaborations ]

    Is there a point in adding that to Awk? (Just interested in your
    opinion.) Personally if I want OO in scripting I'd rather choose
    any [scripting] language that supports it inherently (by design).

    Janis

    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Manuel Collado@mcollado2011@gmail.com to comp.lang.awk on Wed Oct 16 17:03:00 2024
    From Newsgroup: comp.lang.awk

    El 13/10/24 a las 20:19, Kaz Kylheku escribió:
    ...
    You can pass associative arrays down into functions, but not
    return them, or assign them from one variable to another.

    Well, instead of
    arr = a_func(args)
    you can modify a_func to have
    a_func(args, arr)

    And it is customary to write a generic array copy function.
    a_copy(arr1, arr2)

    HTH.
    --- Synchronet 3.20a-Linux NewsLink 1.114
  • From Kaz Kylheku@643-408-1753@kylheku.com to comp.lang.awk on Wed Oct 16 18:49:00 2024
    From Newsgroup: comp.lang.awk

    On 2024-10-16, Manuel Collado <mcollado2011@gmail.com> wrote:
    El 13/10/24 a las 20:19, Kaz Kylheku escribió:
    ...
    You can pass associative arrays down into functions, but not
    return them, or assign them from one variable to another.

    Well, instead of
    arr = a_func(args)
    you can modify a_func to have
    a_func(args, arr)

    I understand how to get array data out of a function.

    This breaks the abstraction and is also monstrously inefficient.

    Imagine that objects are modeled with associative arrays. Now you have
    to copy every time you want to simulate returning an object
    from a function.

    If the objects are treated as having mutable properties, the semantics
    is wrong. You can't return an object by copy if you need the caller
    to be able to mutate the original.

    HTH.

    No, it doesn't, sorry.
    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca
    --- Synchronet 3.20a-Linux NewsLink 1.114