16.12.2025 17:19:26 [email protected]:
> Quoth sirjofri via 9fans <[email protected]>:
> It's a subtly wrong feature -- it looks cute, but doesn't
> generalize well in C. Finishing it would imply garbage
> collection (or at least destructors), which have their
> own disadvantages.
>
> It may work for some things. This, for example, is fine:
>
>         typestr mpint ...;
>
>         mpint *x = mpnew(42);
>         mpint *y = mpnew(123);
>         mpint *z = x * y; //ok, fine
>         mpfree(x);
>         mpfree(y);
>
> but what about:
>
>         mpint *x = mpnew(42);
>         mpint *y = mpnew(123);
>         mpint *z = x * (y - x) * (y - x);
>         mpfree(x);
>         mpfree(y);
>
> There are intermediate expressions along the way
> which would need to be allocated; who frees them?

Well, that makes a lot of sense. I guess I never encountered these issues 
because I only used it with smaller structures that I can easily copy (by 
value). A feature like that should accommodate for the whole language though, 
which it can't. Thanks for clarifying that.

sirjofri

------------------------------------------
9fans: 9fans
Permalink: 
https://9fans.topicbox.com/groups/9fans/T7ee24291af957db7-M28284f002852fd0b205cd5ec
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

Reply via email to