emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Visuwesh <visuweshm@gmail.com>
To: Org Mode List <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] Add support for tables in Calc src block :var
Date: Fri, 13 Dec 2024 16:36:42 +0530	[thread overview]
Message-ID: <87frmr3kql.fsf@gmail.com> (raw)
In-Reply-To: <87h677ua5c.fsf@ucl.ac.uk> (Eric Fraga's message of "Fri, 13 Dec 2024 10:53:19 +0000")

[வெள்ளி டிசம்பர் 13, 2024] Fraga, Eric wrote:

> Response below/inline for email Visuwesh wrote:
>> (original email sent 13 Dec 2024 at 14:32)
>> 
>> Update x := 3 and y first.  Then update `a' and `z'.  `z' will be 10.6.
>> Now update x := 2, and update `z' and `a'.  `z' updates to 5.4 as shown
>> above but `a' remains 9!  
>
> Yes, this is expected behaviour.  Calc assumes a sequential evaluation,
> especially when the same variable is given a value more than once.  It's
> not like most modelling languages which look at the ensemble of
> equations simultaneously.

I assumed this was the case.  It does make sense when you take the whole
picture together.  You are likely to use the same variable name (such as
T for temperature) everywhere so it would be best to use the nearest
one.

> [...]
>
>> Which begs the question: what should be `x'?
>
> Ideally, it would follow the Calc convention and would be the value last
> given (before point, where the table is), I guess.

When we have

    x := 3

    | 1 | 3 |
    #+TBLFM:$2=$x

    x := 6

    | 1 | 6 |
    #+TBLFM:$2=$x

value of `x' for the first table should be 3, and for the second 6.
However, when we have something like

    x := 3
    a := 2 * x
    x := 2
    z := 0.5 * x

    | 1 | |
    #+TBLFM:$2=$x*$z

what should $2 evaluate to?  $z is straight-forward: $z=1.  But what
about $x?  Should it be 2 or 3?  If we go by Calc's convention, it
should be 3.  Do you agree?

> But, at least, for simple cases where variables are not overwritten,
> what you have done would be sufficient (and a really nice addition to
> the Calc package!).
>
> I intend to use it for sure.

I am glad to be of help, and hope the quick hack actually works
reliably.


  reply	other threads:[~2024-12-13 11:07 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-16  3:45 [PATCH] Add support for tables in Calc src block :var Visuwesh
2024-03-16  9:52 ` Ihor Radchenko
2024-03-16 11:37   ` Visuwesh
2024-03-16 12:19     ` Ihor Radchenko
2024-03-16 12:34       ` Visuwesh
2024-03-18 12:48         ` Fraga, Eric
2024-03-18 15:29           ` Visuwesh
2024-03-18 15:45             ` Fraga, Eric
2024-03-30 13:04           ` Visuwesh
2024-04-03 12:43             ` Fraga, Eric
2024-12-13  7:31               ` Visuwesh
2024-12-13  9:02                 ` Visuwesh
2024-12-13 10:53                   ` Fraga, Eric
2024-12-13 11:06                     ` Visuwesh [this message]
2024-12-13 11:48                       ` Fraga, Eric

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

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87frmr3kql.fsf@gmail.com \
    --to=visuweshm@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).