On Mon, Oct 9, 2017 at 3:52 PM, Ralf Hemmecke <[email protected]> wrote: > On 10/09/2017 02:39 AM, oldk1331 wrote: >> Let "Partial" stands for the global GENSYM() solution and "Maybe" >> stands for the "Rep := List R" solution. >> Then we still need to pick a default: what should 'subtractIfCan' return? > > In fact, I would choose the one that works faster and has minimal memory > usage. But actually, I tend to want a "canSubtract?" function. > > As you mentioned earlier "canSubtract?" might in some cases lead to > recomputation whereas "subtractIfCan" might allocate memory that is not > needed if the computation fails. So what would be the best choice here? > Probably, to provide both? I think a test function is anyway a good > idea. There might be situation where it is only necessary to check if > subtraction is possible, but the actual value is not needed. (Of course, > I do not only speak for subtractIfCan, but also for similar cases.)
It's probably better to offer optimized version in "hotspot code" found by profiler, for example in GroebnerInternalPackage. > List(X): NIL or a pointer to a record r > where r holds a value of type X and a NIL pointer > Record(x: X): NIL or a pointer to a value of type X > > So the List version stores an unnecessary NIL pointer together with a > heap allocation for a Record(x: X, next: Pointer). You are misleading here. List with one element is CONS(X, NIL) Record with one slot is CONS(X, NIL) They are identical. > This is the actual reason why Record(x: X) seems better to me. And I > don't care about the "pretend" in this case, because I consider such a > "Partial" domain as a very low-level domain that would have to be > changed with the runtime support of the language. > > Ralf BTW, what's your opinion on naming? -- You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/fricas-devel. For more options, visit https://groups.google.com/d/optout.
