From: "sirjofri via 9fans" <9fans@9fans.net>
To: 9fans <9fans@9fans.net>
Subject: Re: [9fans] Typestr usage (inspired by libgeometry)
Date: Tue, 16 Dec 2025 19:25:40 +0100 (GMT+01:00) [thread overview]
Message-ID: <ea261aa2-0018-40ce-bb66-0cc656fc4d56@sirjofri.de> (raw)
In-Reply-To: <9B381DFBBE425AD6AD846363E0251600@eigenstate.org>
16.12.2025 17:19:26 ori@eigenstate.org:
> Quoth sirjofri via 9fans <9fans@9fans.net>:
> 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
next prev parent reply other threads:[~2025-12-16 19:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-16 15:35 [9fans] Typestr usage (inspired by libgeometry) sirjofri via 9fans
2025-12-16 16:17 ` ori
2025-12-16 18:25 ` sirjofri via 9fans [this message]
2025-12-16 19:32 ` Skip Tavakkolian
2025-12-17 12:03 ` arnold
2025-12-17 0:29 ` Matthew Veety
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ea261aa2-0018-40ce-bb66-0cc656fc4d56@sirjofri.de \
--to=9fans@9fans.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).