Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Referenced identifier not available in context
PostPosted: Wed Jul 03, 2013 12:04 pm 
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


Report this post
Top
  
Reply with quote  
 Post subject: Re: Referenced identifier not available in context
PostPosted: Fri Sep 13, 2013 6:36 pm 
Nobody knows an answer?


Report this post
Top
  
Reply with quote  
 Post subject: Re: Referenced identifier not available in context
PostPosted: Wed Sep 18, 2013 10:23 am 

Joined: Wed May 25, 2005 4:16 pm
Posts: 275
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: Referenced identifier not available in context
PostPosted: Thu Sep 19, 2013 12:03 pm 
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


Report this post
Top
  
Reply with quote  
 Post subject: Re: Referenced identifier not available in context
PostPosted: Tue Sep 24, 2013 11:28 am 

Joined: Tue Jun 23, 2009 10:33 pm
Posts: 51
Location: Kaiserslautern
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: Referenced identifier not available in context
PostPosted: Tue Sep 24, 2013 3:16 pm 
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();


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

It is currently Fri May 13, 2022 10:56 am
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group