Singular
http://www.singular.uni-kl.de/forum/

Referenced identifier not available in context
http://www.singular.uni-kl.de/forum/viewtopic.php?f=10&t=2267
Page 1 of 1

Author:  jack [ Wed Jul 03, 2013 12:04 pm ]
Post subject:  Referenced identifier not available in context

Hello,


why the following setup does not work,
and is this a desired behaviour?

Consider .lib files 'main.lib' and 'extern.lib'

Code:
// 'main.lib':
proc callExternLib()
{
   ring rng= 0,x,dp;
   reference ref= rng;
   accessReferencedRing(ref);
}


Code:
// 'extern.lib'
proc accessReferencedRing(ringRef)
{
     def name = attrib( ringRef, "name" );
}


Then the following examle triggers an error:
Code:
LIB "main.lib";
LIB "extern.lib";

callExternLib();
// leads to ? Referenced identifier not available in current context

Author:  Guest [ Fri Sep 13, 2013 6:36 pm ]
Post subject:  Re: Referenced identifier not available in context

Nobody knows an answer?

Author:  hannes [ Wed Sep 18, 2013 10:23 am ]
Post subject:  Re: Referenced identifier not available in context

rng is a local variable of the routine callExternLib.
Therefore it is not available in another routine.
Hide this fact via the use of reference does not help.
(Remember: reference is a reference to the name
of another variable.)

PS: using reference for rings is a very bad idea: there are special rules
for the name resolution of rings which do not apply to reference.
And: assignment of rings do not produce a copy.

Author:  Jack [ Thu Sep 19, 2013 12:03 pm ]
Post subject:  Re: Referenced identifier not available in context

hannes wrote:
PS: using reference for rings is a very bad idea: there are special rules
for the name resolution of rings which do not apply to reference.
And: assignment of rings do not produce a copy.



Unfortunately I have to pass rings by reference, since otherwise 'attrib' does not work as expected,
see the bug report in track, ticket 502 (cannot post url here)

Is the issue description understandable, or should I try to improve it?


Thanks,


Jack

Author:  malex [ Tue Sep 24, 2013 11:28 am ]
Post subject:  Re: Referenced identifier not available in context

if you only need to set an attribute to a single current ring -
did you try to access it via basering in accessReferencedRing directly (without references) instead?

hope that helps,
O.

Author:  Jack [ Tue Sep 24, 2013 3:16 pm ]
Post subject:  Re: Referenced identifier not available in context

malex wrote:
if you only need to set an attribute to a single current ring -
did you try to access it via basering in accessReferencedRing directly (without references) instead?

hope that helps,
O.

Thanks,

bu my minimal example was insufficient.
In my code I expect that 'attrib' works correctly also for non-active rings.

But I do not want to mixture up the two different issues.
This thread is about references across libraries and in my opinion it is a must -
it is possible to give a myriad of minimal examples, which leads to serious restrictions if references across libraries are not supported.

How should a user manipulate data structures which contains multiple references to the same object?
In case there is an existimg library routine for manipulation of that data, is the user forced to replace all (multiple) references
with hard copies? or has he to copy/ all operations into his own library to be able to use references as parameters ??

What are the arguments not to support or not to allow references across libraries?


Jack

Updated minimal failing example:

system("reference");

proc setAttrib( rng, attrubuteName, attributeVal)
{

attrib( rng, attrubuteName, attributeVal);

}

proc setAttribOfRef( pRngRef, attrubuteName, attributeVal)
{

attrib( pRngRef ,attrubuteName, attributeVal);

}

proc minimalExample()
{

string attributeName = "name";
string attributeVal = "it works!";
ring parentRing = integer,(x,y,z),dp;
ring childRing = integer,(x,y),dp;

setring childRing;

setAttrib( parentRing, attributeName, attributeVal );

if ( attrib( parentRing, attributeName )<> attributeVal )
{

print("setting attrubute by passing ordinary copy failed");

}
else {

print("setting attrubute by passing ordinary copy succeeded");

}

reference rngRef = parentRing;
setAttribOfRef( rngRef,attributeName,attributeVal);


if ( attrib( parentRing, attributeName )<> attributeVal )
{

print("setting attrubute by passing reference failed");

}
else {

print("setting attrubute by passing reference succeeded !");

}

}

minimalExample();

Page 1 of 1 All times are UTC + 1 hour [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/