Re: Type inference oddity with this_program

"H. William Welliver III" <[email protected]>
Newsgroups gmane.comp.lang.pike.user
Message-ID <[email protected]>
Isn't /this_program/ a function (as is /this_object/, but not /this/, which isn't?) 

Try making it a function call and it should work just fine. 

Bill

Sent from my iPhone

> On Apr 8, 2014, at 4:58 AM, Chris Angelico <[email protected]> wrote:
> 
> Example code:
> 
> constant label_xyz="XYZ";
> int main()
> {
>    foreach (indices(this_program),string const)
>    {
>        //program me=this_program; write("%O\n",me[const]);
>        write("%O\n",this_program[const]);
>    }
> }
> 
> This produces the following error:
> 
> thisprog.pike:8:Indexing on illegal type.
> thisprog.pike:8:Got     : function( : object(is
> program(/home/rosuav/thisprog.pike))).
> thisprog.pike:8:Index   : string.
> Pike: Failed to compile script.
> 
> If the program is retained in a separate variable (see the
> commented-out alternative), it works fine, and correctly fetches up
> the value of the constant. Using this[const] also works fine. But
> this_program[const], for some reason, is thought to be looking at a
> function (which it kinda is; calling a program will return an object
> of that type, so the signature is more-or-less right).
> 
> This oddity is visible on Pike 7.8.700 on Windows and 8.0.1 on Linux.
> 
> Is this a bug, or am I misunderstanding this_program?
> 
> ChrisA
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.