Reported bug to consider

182 views
Skip to first unread message

Antonio Linares

unread,
Feb 25, 2022, 5:35:43 AM2/25/22
to Harbour Developers
A Harbour user has reported a bug, according to Clipper docs:


We do appreciate your opinions

many thanks

Antonio

Bacco

unread,
Feb 25, 2022, 5:43:28 AM2/25/22
to harbour-devel
Does the aforementioned code works on Cl*pper as user expected?



--
You received this message because you are subscribed to the Google Groups "Harbour Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-deve...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/harbour-devel/8ba8230a-fc09-4144-9412-4de5145d0740n%40googlegroups.com.

Bacco

unread,
Feb 25, 2022, 5:54:02 AM2/25/22
to harbour-devel
That is always the first question, of course.

But it seems that the use of "return a reference" in the mentioned
docs lead to a wrong conclusion. I hope this snippets can clarify
what it means to return a reference;

Here we are returning a value:
a := {1,2,3}
? ATAIL(a)

And here, returning a "reference", as the value is in fact an array:
a := {1,2,{3,4,5}}
? ATAIL(a)[2]

ATAIL(a)[2] = 7 works...

It's expected in the first case you cant set a value to another value.

Regards
Bacco


Alex Strickland

unread,
Feb 25, 2022, 6:06:24 AM2/25/22
to harbou...@googlegroups.com

Hi

I don't agree that that behaviour is a bug, I consider the fact that it works as Enrico expects in xHarbour to be a bug.

This quote:

It can be used in applications as shorthand for
<aArray>[LEN(<aArray>)] when you need to obtain the last element of an
array.

does not imply the behaviour he expects in my opinion.

Basically an expression cannot return a L-Value that can be assigned to unless it is a reference.

--

Regards

Alex

--
You received this message because you are subscribed to the Google Groups "Harbour Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-deve...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/harbour-devel/8ba8230a-fc09-4144-9412-4de5145d0740n%40googlegroups.com.
--

Francesco Perillo

unread,
Feb 25, 2022, 6:08:26 AM2/25/22
to harbou...@googlegroups.com
Exactly.
ATAIL( a ) is a function, whatever it returns, you can't assign a value to it. Not in Clipper. Don't be mislead by some other languages.

More, please test it in xHarbour:
a := {1,2,3,4,5}
b := ATAIL(a)
? b
b := 8
? ATAIL(a)

In Harbour it always returns 5.

Looking at the c code, atail returns a copy of the last object in the array... so I can't even understand how can it work in xHarbour if the code is the same...
 

José M. C. Quintas

unread,
Feb 25, 2022, 10:55:49 AM2/25/22
to harbou...@googlegroups.com
Yes, and no.

Atail() returns last array, ok.

array may be allways as reference, ok.

But if element is not an array, it is not by reference.

a := { { 1,2}, { 3,4} }

b := Atail(a) // returns an array

b[ 2 ] := 10 // change value

? Atail( a )[ 2 ] // show 10

this is not the same as

a:= { 1,2,3,4,5}

b := Atail(a) // returns a number

b := 10 // do not change a array

? Atail( a ) // show 5

Do you make the test using Clipper?

José M. C. Quintas

Klas Engwall

unread,
Feb 25, 2022, 11:04:29 AM2/25/22
to harbou...@googlegroups.com
Hi Antonio,

> A Harbour user has reported a bug, according to Clipper docs:
>
> Enrico Maria Giordano reported bug
> <http://forums.fivetechsupport.com/viewtopic.php?f=18&t=41455&start=0&sid=0d8f9902f25fadfb880f19312b4aa537>
>
> We do appreciate your opinions

Clipper's opinion below :-)

L:\clip5\TEST>clipper enrico
Clipper (R) 5.2e
Copyright (c) 1985-1995, Computer Associates International, Inc.
Microsoft C Floating Point Support Routines
Copyright (c) Microsoft Corp 1984-1987. All Rights Reserved.
342K available
Compiling ENRICO.PRG
ENRICO.PRG(5) Error C2042 Invalid lvalue
1 error

Regards,
Klas

Antonio Linares

unread,
Feb 25, 2022, 11:29:28 AM2/25/22
to harbou...@googlegroups.com
many thanks to all

best regards

--
You received this message because you are subscribed to a topic in the Google Groups "Harbour Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/harbour-devel/ZPvgH-Lt1sY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to harbour-deve...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/harbour-devel/072eb811-5fae-c32f-783c-09290ce266de%40engwall.com.


--
Antonio Linares
www.fivetechsoft.com

José M. C. Quintas

unread,
Mar 4, 2022, 2:55:58 PM3/4/22
to harbou...@googlegroups.com

a := { 1, 2, 3 }

Test( a )

? a[ 3 ] // return 10

FUNCTION Test( a )

a[ 3 ] := 10

RETURN Nil

Works like Test( @a ), but not exactly the same.

This do not occurs with another value type, only with arrays.


José M. C. Quintas

Reply all
Reply to author
Forward
0 new messages