Re: Doubt about compiler error of `has_value` with arrays

2025-03-19 Thread Marcos Cruz
Henrik Grubbström escribió/skribis/wrote/scrit (2025-03-14T14:32:56+0100): > the error is triggered because the compiler has sufficient type > information to determine that the respective calls will always fail. It makes sense, yes. Thank you for the explanation. -- Marcos Cruz http://programa

Re: Doubt about compiler error of `has_value` with arrays

2025-03-14 Thread Henrik Grubbström
Hi Marcos. On Thu, 13 Mar 2025, Marcos Cruz wrote: I'm using Pike v8.0 release 1738 on Debian 12.9. I got this: ``` int x; x = has_value(({ 1, 2, 3, 4 }), -100); // result: 0 x = has_value(({ 1, 2, 3, 4 }), 0); // result: 0 x = has_value(({ 1, 2, 3, 4 }), 4); // result: 1 x = has_value(({ 1,

Re: Doubt about compiler error of `has_value` with arrays

2025-03-13 Thread William Welliver
Hmm. I’m not sure where I fall on this. I can appreciate that the haystack may have a type and you might want to restrict the type over the operand in some situations but it seems like a method like has_value should be lenient with respect to the value being searched for. Sent from my iPhone

Re: Doubt about compiler error of `has_value` with arrays

2025-03-13 Thread Chris Angelico
On Fri, 14 Mar 2025 at 03:31, Marcos Cruz wrote: > So somehow the problem happens when the array argument is a literal, > both in hilfe and in a file. When you use literals, yes, has_value expects that the argument makes sense. But normally you'll be using a variable for one or both of its argume

Re: Doubt about compiler error of `has_value` with arrays

2025-03-13 Thread Marcos Cruz
will...@welliver.org escribió/skribis/wrote/scrit (2025-03-13T12:16:36-0400): > In the meantime, you can get around this error by using the following: > > > int x; > > array y = ({ 1, 2, 3, 4 }); > > x = has_value(y, 5); I know hilfe has some limitations, but the problem happens to me both in hi

Doubt about compiler error of `has_value` with arrays

2025-03-13 Thread Marcos Cruz
I'm using Pike v8.0 release 1738 on Debian 12.9. I got this: ``` int x; x = has_value(({ 1, 2, 3, 4 }), -100); // result: 0 x = has_value(({ 1, 2, 3, 4 }), 0); // result: 0 x = has_value(({ 1, 2, 3, 4 }), 4); // result: 1 x = has_value(({ 1, 2, 3, 4 }), 5); Compiler Error: 1: Bad argument 2 to

Re: Doubt about compiler error of `has_value` with arrays

2025-03-13 Thread william
Hi Marcos! If you're using hilfe, you may occasionally notice that perfectly legal code doesn't work. That's a result of the "magic" that makes incremental compilation and evaluation in hilfe possible. I think this is one of those occasions. I'm sure that someone with understanding of how hilf

Re: Arrays

2021-10-18 Thread Duke Normandin
On Tue, 19 Oct 2021 10:07:43 +1100 Chris Angelico wrote: [snip] > > set warnings strict That worked swell in my Hilfe! Thx -- Duke

Re: Arrays

2021-10-18 Thread Duke Normandin
On Tue, 19 Oct 2021 10:07:43 +1100 Chris Angelico wrote: > On Tue, Oct 19, 2021 at 10:03 AM Duke Normandin > wrote: > > > > On Tue, 19 Oct 2021 09:26:34 +1100 > > Chris Angelico wrote: > > > > > On Tue, Oct 19, 2021 at 9:19 AM Duke Normandin > > > wrote: > > > > > > > > Pike v8.0 release 702 r

Re: Arrays

2021-10-18 Thread Chris Angelico
On Tue, Oct 19, 2021 at 10:03 AM Duke Normandin wrote: > > On Tue, 19 Oct 2021 09:26:34 +1100 > Chris Angelico wrote: > > > On Tue, Oct 19, 2021 at 9:19 AM Duke Normandin > > wrote: > > > > > > Pike v8.0 release 702 running Hilfe v3.5 (Incremental Pike > > > Frontend) > > > > > > > array(string)

Re: Arrays

2021-10-18 Thread Duke Normandin
On Tue, 19 Oct 2021 09:26:34 +1100 Chris Angelico wrote: > On Tue, Oct 19, 2021 at 9:19 AM Duke Normandin > wrote: > > > > Pike v8.0 release 702 running Hilfe v3.5 (Incremental Pike > > Frontend) > > > > > array(string) flat = ({"this", "that", "the", "other"}); > > > flat[1];(4) Result: "that"

Re: Arrays

2021-10-18 Thread Chris Angelico
On Tue, Oct 19, 2021 at 9:19 AM Duke Normandin wrote: > > Pike v8.0 release 702 running Hilfe v3.5 (Incremental Pike Frontend) > > > array(string) flat = ({"this", "that", "the", "other"}); > > flat[1];(4) Result: "that" > > > flat[1]=3; > (5) Result: 3 > > > flat[1]; > (6) Result: 3 > > I was und

Arrays

2021-10-18 Thread Duke Normandin
Pike v8.0 release 702 running Hilfe v3.5 (Incremental Pike Frontend) > array(string) flat = ({"this", "that", "the", "other"}); > flat[1];(4) Result: "that" > flat[1]=3; (5) Result: 3 > flat[1]; (6) Result: 3 I was under the impression that array(string) would exclude any other data types but s