all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Maxim Nikulin <manikulin@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: Bug: Can’t assign to hline relative reference
Date: Thu, 29 Oct 2020 19:40:37 +0700	[thread overview]
Message-ID: <rned86$4gb$1@ciao.gmane.io> (raw)
In-Reply-To: <efa08c80-893f-7cd9-6bff-f36158ecc3ca@lambda.cx>

2020-10-23  Dante Catalfamo wrote:
> That seems to work for the most part, but now I'm experiencing a strange
> difference when evaluating. If I use a formula like
>   
> #+TBLFM:@2$3..@23$3=if($2!=0,12*$2,$3);%.2f::@24$2=vsum(@I..@II);%.2f::@24$3=vsum(@I..@II);%.2f
> 
> The column gets evaluated first, then the sum at the bottom gets
> evaluated, resulting in what I'd expect. But if I use a formula like
> 
> #+TBLFM:@<<$3..@>>$3=if($2!=0,12*$2,$3);%.2f::@24$2=vsum(@I..@II);%.2f::@24$3=vsum(@I..@II);%.2f
> 
> The sum gets calculated first, and the column after, meaning the sum
> doesn't reflect any changes made before calculation. I find this pretty
> strange considering the formulas are in the same order. Do formulas
> involving relative references get calculated last for some reason?

Interesting... However my curiosity is not strong enough to find 
appropriate place in the code.

Either I never tried such combination of references (I use @>$2=... for 
the last row) or I have not expected reliable evaluation order and just 
hit C-c C-c several times.

It seems that single cell formulas are calculated later than ranges

| a | c | b |
|---+---+---|
| 2 |   |   |
| 3 |   |   |
| 4 |   |   |
| 5 |   |   |
| 6 |   |   |
| 7 |   |   |
|---+---+---|
|   |   |   |
#+TBLFM: @<<$3..@>>$3=$1*2 :: @<<$2..@<<<$2=$3*3 :: @5$2..@6$2=$3*4 :: 
@4$2=$3*5 :: @>>$2=$3*6

| a |  c |  b |
|---+----+----|
| 2 |  0 |  4 |
| 3 |  0 |  6 |
| 4 |  0 |  8 |
| 5 |  0 | 10 |
| 6 |  0 | 12 |
| 7 | 84 | 14 |
|---+----+----|
|   |    |    |
#+TBLFM: @<<$3..@>>$3=$1*2 :: @<<$2..@<<<$2=$3*3 :: @5$2..@6$2=$3*4 :: 
@4$2=$3*5 :: @>>$2=$3*6

Notice zeroes for @<<..@<<< but not for @>>. Even more funny that 
@>>>>>>>$2..@>>>>>>$2=$3 instead of @<<$3..@<<<$3 give non-zero values 
for the second and third rows. Anyway I do not plan to memorize such rules.

By the way, I have noticed that @<<$3..@>>$3=... likely could be 
replaced by just $3=... and it is evaluated quite early in such form. 
Skimming through the manual previous times, I missed the point of 
"column formulas" https://orgmode.org/manual/Column-formulas.html or
[[info:org#Column formulas]] and have noticed the details just today.



  reply	other threads:[~2020-10-29 12:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-21  1:14 Bug: Can’t assign to hline relative reference Dante Catalfamo
2020-10-21 12:43 ` Daniel Herzig
2020-10-21 16:14   ` Dante Catalfamo
2020-10-22 12:04     ` Maxim Nikulin
2020-10-22 19:56       ` Dante Catalfamo
2020-10-29 12:40         ` Maxim Nikulin [this message]
  -- strict thread matches above, loose matches on Subject: below --
2020-10-20 21:39 Dante Catalfamo

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='rned86$4gb$1@ciao.gmane.io' \
    --to=manikulin@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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.