On Wed, 3 Mar 2021, Sven Schreiber wrote:

Am 03.03.2021 um 13:31 schrieb atecon:

with latest git version under Ubuntu 18.04 I obtain a crash when
running the following script:
Confirmed with a recent snapshot on Windows. That one looks pretty bad,
but...

function void simple (const int N[2::])

...it doesn't crash anymore for me when removing "const". And only Artur
would put a const in front of an int ;-)

Actually, I believe it is not supported by hansl to do "const int": The
guide says "the const modifier may be used... for all the types that
support the pointer apparatus".

That's right. "const" doesn't have any effect when placed in front of (non-pointerized) scalar arguments of any sort. Illustration:

<hansl>
function void simple (const int N[2::])
  printf "very simple (%d)\n", N
  # no error flagged here
  N = 24
end function

function void dimple (const matrix m)
  printf "very dimple\n"
  # this does give an error
  m = m + 5
end function

k = 7
simple(k)
print k # note: k is still 7
dimple(I(3))
</hansl>

I guess this is a buglet: either "const" should be disallowed for plain scalar arguments, or else it should prevent changing the argument inside the function (although the caller will not inherit a change in any case).

Allin
_______________________________________________
Gretl-devel mailing list -- gretl-devel@gretlml.univpm.it
To unsubscribe send an email to gretl-devel-le...@gretlml.univpm.it
Website: 
https://gretlml.univpm.it/postorius/lists/gretl-devel.gretlml.univpm.it/

Reply via email to