Opened 12 years ago
Closed 12 years ago
#307 closed bug (fixed)
Inconsistent behaviour between return values of proc calls() and operators (like[])
Reported by: | dreyer | Owned by: | somebody |
---|---|---|---|
Priority: | minor | Milestone: | 3-1-3 and higher |
Component: | dontKnow | Version: | 3-1-2 |
Keywords: | Cc: |
Description
Hi alltogether! Using proc definitions, one can do something like this:
> proc huhu() . { . print(17); . } > proc hihi() . { . return(huhu); . } > hihi()(); 17
In constrast, the following does not work:
> proc huhu() . { . print(17); . } > list ll=(huhu); > ll[1](); // libname : // procname : huhu // type : singular ? error occurred in or before STDIN line 16: `ll[1]();` skipping text from `)` error at token `)`
It shouldn't make a difference, whether one gets a callable object (like proc) via another proc or using an operation. BTW, the following works as expected:
> def ll_1=ll[1]; > ll_1(); 17
The issue occurs on all objects, which are able to perform the '(' operation.
Best regards,
Alexander
Change History (6)
comment:1 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:2 Changed 12 years ago by
Resolution: | fixed |
---|---|
Status: | closed → reopened |
not that easy: had to undo the changes
comment:3 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
fixed in the following sense:
proc p {"p";} list l=p; proc(l[1])();
Note, that proc(...) is necessary for calling procedures in lists.
comment:4 Changed 12 years ago by
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Maybe, the example was to simplistic. The new solution works for proc
only, see the overloaded attrib operator for a blackbox object from the pyobject branch:
> pyobject pystr="pypyp"; found bb:pyobject:529 (table:0) bb-type 529 bb-assign: bb=7f2dfc9b0030 > pyobject(attrib(pystr, "count"))("y"); found bb:pyobject:529 (table:0) <built-in method count of str object at 0x7f2dfc919930> ? error occurred in or before STDIN line 2: `pyobject(attrib(pystr, "count"))("y");` ? last reserved name was `attrib` skipping text from `"` error at token `)`
PS: The first attempt fixed that issue for me.
comment:5 Changed 12 years ago by
Making that example more like above:
> python_run("def func(): return 17"); > func(); 17 > list ll=(func); > pyobject(ll[1])(); found bb:pyobject:529 (table:0) <function func at 0x7fae781f3500> ? error occurred in or before STDIN line 4: `pyobject(ll[1])();` skipping text from `)` error at token `)`
But again, one needs the pyobject branch.
comment:6 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Ok, got it, the blackbox also needs the proc operation.
So
> proc(ll[1])(); 17
is fine
grammar modified to allow such wild constructions