On 1/30/19 5:13 PM, Ralf Hemmecke wrote:
> On 1/30/19 2:36 AM, oldk1331 wrote:
>> Yes, this is a bug introduced during my cleanup of Factored domain.
>
> Thanks for fixing it so quickly.
>
>> Now to think about it, if we really want to avoid extra allocation,
>> a better approach is to use local variable:
>>
>>     __one := [1, empty()]
>>     1 == __one
>
> Honestly, it would surprise me if that works. In fact, I believe in
> Aldor that would even lead to a subtle bug. The Aldor compiler reorders
> == and := assignments. == assignments always come first. Maybe Peter
> Broadbery can say more about it.
>
> Have you checked whether in FriCAS
>
>     1 == [1, empty()]
>
> i.e., the current situation, really leads to allocation of a new record
> each time 1 is used?

Hmm, I checked, I was wrong. Each usage of "1" doesn't leads to a new
allocation.

> In fact, it keeps confusing me.
>
> In Aldor, if write something like
>
>   foo: % == [1, empty()]
>   bar(): % == [1, empty()]
>
> then in the use of bar() I would expect a new allocation every time
> bar() is used. But not so for foo. In Aldor bar is a function but foo is
> a constant (no function call).

I think "foo" and "bar" are the same: the empty parentheses can be omitted.
They are both functions with no arguments.

The thing matters is that "1" is declared as:

    1 : constant -> %

That makes sure function body of "1" is called only once.

So in

    foo1 : () -> %
    foo2 : constant -> %

the function body of "foo1" will run many times and the function body of "foo2"
will run only once.  I didn't know this distinction before...

> I were happy it that would be the same in FriCAS, but 1 in FriCAS is
> ONE() and not really a constant. :-(
>
> Ralf
>

-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/CAGBJN91BZYsLRS70nD9giji%3DSurUgxXOYobJ1hcDtAMd9fDwJg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to