|
From: Colin M. <col...@ya...> - 2025-11-03 07:53:59
|
The updated prototype I posted yesterday handles this.
On 03/11/2025 07:19, Zaumseil René wrote:
>
> Just do a "string map {{ } {}} .." at first.
>
> *Von:*Pietro Cerutti via Tcl-Core <tcl...@li...>
> *Gesendet:* Sonntag, 2. November 2025 09:05
> *An:* Colin Macleod <col...@ya...>
> *Cc:* tcl...@li...; av...@lo...
> *Betreff:* ***CAUTION_Invalid_Partial_Signature*** [Ext] Re: [TCLCORE]
> Fwd: TIP 672 Implementation Complete - Ready for Sponsorship
>
> How does it handle a space between a mathfunc and its parenthesized
> argument list?
>
> % expr {sin (12)}
>
> -0.5365729180004349
>
> --
>
> Pietro Cerutti
>
> I've pledged to give 10% of income to effective charities and invite
> you to join me.
>
> https://givingwhatwecan.org
>
> Sent from a small device - please excuse brevity and typos.
>
>
>
> On 1 Nov 2025, at 17:50, Colin Macleod via Tcl-Core
> <tcl...@li...> wrote:
>
>
>
> On 30/10/2025 01:18, Andreas Leitgeb wrote:
>
> - [= ...] with a modified expr-language using barewords as variable
>
> names would probably solve many (if not most) of the cases, where
>
> [expr {...}] really "hurts" for its verbosity.
>
> Here is a pure Tcl implementation of that:
>
> proc = args {
> set ex [join $args]
> set exp [regsub -all
> {(::)?[[:alpha:]]([[:alnum:]_]|::)*([^[:alnum:]_(]|$)} $ex {$&}]
> uplevel expr $exp
> }
>
> This just finds all the possible variable names in the expression,
> prefixes them with $ and then runs expr on the result. The regex
> is a little complicated because:
>
> * The variable name could include :: at the beginning or in the
> middle for namespacing.
> * We disallow single colon : within the name because that
> creates ambiguity with the ternary operator ?: .
> * We also disallow array references because we can't distinguish
> them from mathfunc calls.
>
> The fact that this can be implemented in pure Tcl shows that it
> doesn't require any change to the dodekalogue rules, and so there
> is no consequence for subst either.
>
> Of course a real implementation should be done in C. It could
> then also be possible to implement the extension Kevin Kenny
> suggested of adding `=` as an assignment operator as in C within
> an expression, and perhaps even chaining multiple assignments with
> `,` .
>
> I saw the `expr` question is on the agenda for the call on
> Monday. I don't usually join these calls but I would join it for
> this issue except that I have an urgent dentist's appointment at
> that time. Perhaps I should create a new TIP for this proposal?
>
> Colin.
>
> _______________________________________________
> Tcl-Core mailing list
> Tcl...@li...
> https://lists.sourceforge.net/lists/listinfo/tcl-core
> |