Wednesday, 2023-06-07

lkclvaino[m], nice to have you around, sorry we had some "interesting" news that needed fast evaluation, normally the coffee meetings are much more free-form if you know what i mean01:20
lkclghostmansd[m], ohh like "are the bit-fields of these operands overlapping"? that sort of thing01:21
lkclmy biggest concern about visitor-walking is that the act of "visiting" (the actual tree-walking) be *entirely* separated from "the action(s) taken"01:23
lkclthat's extremely important, and is something that the python-html-visitor gets right01:24
lkcland if the *entire* database is constructed in terms of "lists of fields" and "child-lists" - just like in the python *2.7* - then it is a matter of implementing one function to do that: do_a_visit_walk()01:26
lkcllook-up by classname is neat.01:27
lkcli can't quite "consciously" guess what you mean about __getattr__ but subconsciously i know you will have a really good idea there :)01:28
lkclsadoon[m]1, tyan server... tyan server... oh - the MIPS64-based Loongson ones? awesome!01:29
lkclghostmansd[m], the solution to "how do i do a filter" is:01:29
lkcl    class VisitFilterByRecord:01:30
lkcl        def __init__(self, filterfn): self.filterfn = filterfn01:30
lkcl        def visit_child_Record(self, node):01:31
lkcl            if self.filterfn(node): self.__current_record = node01:32
lkcl        def visit_child_Record_after(self, node):01:32
lkcl            self.__current_record = None01:32
lkcl        def visit_child_Record_field(self, node):01:32
lkcl            if self.__current_record is None: return01:33
lkcl            ....01:33
lkcl            ....01:33
lkclin other words the Visitor has *no control* over how deep the walking goes, the do_visitor_walk() function *will* go in a fixed-order over the entire database, down every single field in a strict breadth-first tree-walk01:35
lkcland the nice thing about having the 3-functions is:01:35
lkclyou can have the visitor-instance do Polish Notation (op A B), Reverse-polish Notation (A B op) or standard notation (A op B) depending on whether you use the pre-child, child, or post-child function to push/pop stuff off of a stack01:37
lkcl(where the stack is, you guessed it, a local class-member-variable of the Visitor-instance, *not* a fixed type-defined base-class member of a pre-defined suite of visitors)01:39
lkcloh btw do look up "__call__()"01:45
lkcl*extremely* useful01:45
lkclwhat duh... :)
lkclnice.. except argh argh the "accept" function is performing the exact explicit-control i don't think should be exposed into the visitor itself01:50
lkcl("controlling" the depth)01:50
*** ghostmansd <ghostmansd!~ghostmans@> has joined #libre-soc08:12
*** ghostmansd <ghostmansd!~ghostmans@> has quit IRC08:17
*** ghostmansd <ghostmansd!~ghostmans@> has joined #libre-soc08:18
*** ghostmansd[hexch <ghostmansd[hexch!~ghostmans@> has joined #libre-soc08:39
*** ghostmansd <ghostmansd!~ghostmans@> has quit IRC08:41
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@> has joined #libre-soc08:52
*** ghostmansd[hexch <ghostmansd[hexch!~ghostmans@> has quit IRC08:55
*** markos_ <markos_!~markos_@user/markos/x-1838887> has quit IRC09:20
*** markos_ <markos_!~markos_@> has joined #libre-soc09:33
*** markos_ <markos_!~markos_@user/markos/x-1838887> has joined #libre-soc09:33
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@> has quit IRC09:40
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@> has joined #libre-soc09:40
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@> has quit IRC09:50
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@> has joined #libre-soc09:51
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@> has quit IRC10:04
vaino[m]lkcl, no problem, it was good to sort of see what's currently going on10:05
lkcltoshywoshy, ping, openpowerbot gone walkies on libera?10:26
lkclprogrammerjake, openpowerbot's gone walkies and i know you had a diff that you identified where rldimi wasn't happy? can you put it into
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@> has joined #libre-soc10:31
*** markos_ <markos_!~markos_@user/markos/x-1838887> has quit IRC10:38
*** openpowerbot <openpowerbot!> has joined #libre-soc10:45
ghostmansd[m]lkcl, I posted some updates on visitors in 1094, please take a look when you have some free time10:54
*** markos_ <markos_!> has joined #libre-soc11:01
*** markos_ <markos_!~markos_@user/markos/x-1838887> has joined #libre-soc11:01
lkclghostmansd[m], ack.11:11
lkcli finally found something that explains:
lkclthe separation between "Visitor" and "Visiting" is *real* important11:14
lkclthe irony is that this is a ridiculously-small amount of code.11:15
lkclghostmansd[m], "Visitable" is still merged with "Visitor".  Visitors should not have "for opcode in node.opcodes:"11:38
lkclthe *Visitable* should have "for opcode in node.opcodes:" and that should be *in Record*, *in Database*, *in SVP64Instruction*11:39
lkcland one of the arguments to it: the visitor.11:39
ghostmansd[m]The link doesn't open11:40
lkclwrong: class SVP64InstructionVisitor(InstructionVisitor): pass11:40
lkclright: class SVP64InstructionVisitor(IVisitable):11:40
lkcli found the original11:40
ghostmansd[m]What's merged? I don't get it.11:40
lkclthe concept of "Visitable" with the concept of "Visitor"11:41
ghostmansd[m]You have Node and the way to visit it11:41
lkclVisitors should - must - *not* do "walking of child objects" themselves11:41
lkclif there is a for-loop on child objects *inside* the Visitor, this is the wrong approach11:42
lkcli'll edit the bugreport comments because that link requires "membership", i didn't realise11:43
ghostmansd[m]So your point is that inside the specific handler we should not manually invoke a loop which iterates?11:43
ghostmansd[m]If so, this can be done.11:43
ghostmansd[m]But this is kinda too restricting, because this is the best way to skip certain exact records.11:44
lkclthe "normal" approach to skipping (filtering) is to have the Visitor keep track (by creating local variables self.__current_record for example)11:46
lkclhmm hmm i am thinking...11:48
lkcli'd really like to see the entire walking (the nested for-loops) be driven by reading self._fields11:49
lkcland... ahhh... then filtering can be done as an *intermediate* stage.11:51
lkcltoshywoshy, thx openpowerbot is back11:51
ghostmansd[m]Hard no on reading a private member field.11:55
ghostmansd[m]Good with explicit property.11:55
ghostmansd[m]And it's already done, it's just that filtering still happens inside the handler. And I don't see how introducing a context makes it better.11:56
ghostmansd[m]But even if I don't see its benefits, I still can do it.11:56
*** ghostmansd[hexch <ghostmansd[hexch!~ghostmans@> has joined #libre-soc12:01
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@> has quit IRC12:04
lkcl*private* member field?  no this is public member fields12:04
lkclall fields are public.  Record.dynamic_operands is public, Record.static_operands is public, yes?12:05
lkclok, i think i can illustrate:12:05
lkclhow with *one function* down at the base class as a staticmember function can you printout the *entire* database structure?12:06
lkclnot the contents12:07
lkcljust the structure12:07
lkcl(it should be possible if every single object used in the entire system has a "fields" member.12:08
lkclmuch as i don't like dataclasses, there is a way to do exactly this12:08
lkcl> But even if I don't see its benefits, I still can do it12:14
lkcli'd very much like you to understand why, rather than "just do it" if you know what i mean12:14
lkclpresently the "picture in my head" is {walker/Visitable}<-{filter_function} -> {Visitor}12:16
lkclbasically separating what is currently *all three* roles in one!12:17
lkcl    def Record(self, node, depth):12:18
lkcl        for operand in node.dynamic_operands:12:18
lkclthis is not a visitor pattern12:18
lkcl            if not in ("PO", "XO"):12:19
lkclthat is the filter12:19
lkcl                desc = f"{}={operand.value}"12:19
lkcl                print(desc, ",".join(map(str, operand.span)))12:19
lkcl*that* is the Visitor!12:19
lkcllet me do that again12:19
lkcl    def Record(self, node, depth):12:19
lkcl        for operand in node.dynamic_operands:12:19
lkclthis is the *Visitable* pattern12:19
lkcl            if not in ("PO", "XO"):12:20
lkclthat is the filter12:20
lkcl                desc = f"{}={operand.value}"12:20
lkcl                print(desc, ",".join(map(str, operand.span)))12:20
lkcl*that* is the Visitor!12:20
lkclall three should be completely separated12:20
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@> has joined #libre-soc12:39
*** ghostmansd[hexch <ghostmansd[hexch!~ghostmans@> has quit IRC12:42
lkclghostmansd[m], i'm slowly beginning to grasp this.  it's difficult to give examples because there are *so many* people who have done "visitor" patterns that aren't actually properly separated.12:47
lkclone of the downsides of python becoming popular :)12:47
lkclguido van rossum was really damn good at this stuff12:47
lkclhe developed python as a teaching-tool as part of working as a university lecturer12:48
lkclwhilst doing his PhD (i think)12:48
sadoon[m]1Slightly bad news: my manager retired and the new one absolutely despises me for.. Many reasons lmao14:14
sadoon[m]1So I'm still going to be busy as I look into my options, most likely finding another job14:14
sadoon[m]1Wish me luck14:14
vaino[m]good luck sadoon, that sounds tough. I hope you find a better place14:18
markos_sadoon[m], what are you looking for? maybe we can help here14:21
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@> has quit IRC14:25
sadoon[m]1Thanks everyone14:35
sadoon[m]1Looking for a local job offer, nothing international. Preferably in teaching14:35
sadoon[m]1There's a lab engineer position open for electronics and electrical engineering, just what I need14:36
sadoon[m]1Closes soon so I need to be very swift about it14:37
markos_well good luck14:38
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@> has joined #libre-soc15:00
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@> has quit IRC15:19
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@> has joined #libre-soc15:21
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@> has quit IRC15:25
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@> has joined #libre-soc15:25
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@> has quit IRC15:30
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@> has joined #libre-soc15:30
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@> has quit IRC15:38
*** yambo <yambo!> has quit IRC16:34
*** yambo <yambo!> has joined #libre-soc16:46
*** lxo <lxo!~lxo@gateway/tor-sasl/lxo> has quit IRC16:50
*** lxo <lxo!~lxo@gateway/tor-sasl/lxo> has joined #libre-soc16:50
*** markos_ <markos_!~markos_@user/markos/x-1838887> has quit IRC18:35
ghostmansd[m]lkcl, what's now wrong with matcher?18:37
ghostmansd[m]That's exactly the same stuff you suggested except that you can have per-type matcher.18:38
ghostmansd[m]It's a callable which gets a node and returns bool.18:39
ghostmansd[m]What exactly "increases" the code in size? Please check base classes. You probably look into concrete visitors with their prints.18:40
ghostmansd[m]As for depth, this comes from AST. I have no problems if the code around bookkeeps it, but it's handy.18:41
ghostmansd[m]Walking _IS_ separate from action. All the walk is done in classes.18:42
ghostmansd[m]Actions are in visitor.18:42
ghostmansd[m]It's only that the action might be "don't match this node as a candidate for calling the action".18:43
ghostmansd[m]Unless you restrict the matching, this is a walk-over-anything-this-has.18:44
ghostmansd[m]No I don't want "isinstance" check with some list instead of inheritance. First, I want to be able to decide what's walked in the corresponding classes, because some of this information is too low-level or too ungrouped (cf. extras). Second, isinstance is probably the most shitty way to do it. It breaks the duck type.18:47
*** markos_ <markos_!> has joined #libre-soc18:48
*** markos_ <markos_!~markos_@user/markos/x-1838887> has joined #libre-soc18:48
ghostmansd[m]In the example you posted with AST, it's the same except that the user might skip some nodes. Yes I do think it's perfectly correct and valid, and in no ways is different to "accept_filter" except that it allows to avoid isinstance checks in accept_filter.18:52
ghostmansd[m]The isinstance check is just implemented in the way like it's done with handler (to the degree they actually do the same thing: invoke per-class __call__ or call a stub).18:53
ghostmansd[m]Treat it as "accept_filter which is callable in a per-class way".18:55
ghostmansd[m]As for using dataclasses.fields, yes this might be the option. I find some information too low-level, but this can be done. However, I want to have higher-level information. You can, for example, what `def extras` returns, and which fields reside in fact. This can be done, but it needs refactoring so that the high-level fields are constructed upon initialization. I don't have time for this yet.19:04
programmerjake> programmerjake, openpowerbot's gone walkies and i know you had a diff that you identified where rldimi wasn't happy?19:27
programmerjakeiirc ghostmansd is the one who found it, not me19:27
programmerjakei don't actually have a diff19:27
programmerjakelkcl ^19:28
*** ghostmansd[m] <ghostmansd[m]!~ghostmans@> has quit IRC19:28
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@> has joined #libre-soc19:34
ghostmansd[pc]lkcl, I think I finally understood what you meant19:38
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@> has quit IRC19:38
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@> has joined #libre-soc19:38
ghostmansd[pc]lkcl, I think I finally understood what you meant19:39
*** markos_ <markos_!~markos_@user/markos/x-1838887> has quit IRC19:40
ghostmansd[pc]Is the whole problem that you don't want visitors to be passed to Whatever.visit() and you want to have Whatever.subnodes instead?19:41
ghostmansd[pc](I'd have used Whatever.__iter__, but it's used for other internal purposes sometimes in insndb's classes).19:42
*** markos_ <markos_!> has joined #libre-soc19:51
*** markos_ <markos_!~markos_@user/markos/x-1838887> has joined #libre-soc19:51
ghostmansd[pc]I'm changing this part. That said, I like the matcher concept, I'm keeping it. I don't want any of this "if isinstance" crap, at all. This will be used just in insndb.Whatever.subnodes call so that I can pass it to insndb.walk as an optional argument.19:57
ghostmansd[pc]Hm. Perhaps matchers won't be of no use at all. Still checking.20:33
*** octavius <octavius!> has joined #libre-soc20:56
ghostmansd[pc]lkcl, ignore the stuff atop, check just
*** libredev <libredev!> has quit IRC21:05
*** ghostmansd[pc] <ghostmansd[pc]!~ghostmans@> has quit IRC21:09
*** octavius <octavius!> has quit IRC21:29
*** ghostmansd[m] <ghostmansd[m]!~ghostmans@> has joined #libre-soc21:32
*** libredev <libredev!> has joined #libre-soc22:33

Generated by 2.17.1 by Marius Gedminas - find it at!