Post a reply
Username:
Note:If not registered, provide any username. For more comfort, register here.
Subject:
Message body:
Enter your message here, it may contain no more than 60000 characters. 

Smilies
:D :) :( :o :shock: :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen:
Font size:
Font colour
Options:
BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON
Disable BBCode
Disable smilies
Do not automatically parse URLs
Confirmation of post
To prevent automated posts the board requires you to enter a confirmation code. The code is displayed in the image you should see below. If you are visually impaired or cannot otherwise read this code please contact the %sBoard Administrator%s.
Confirmation code:
Enter the code exactly as it appears. All letters are case insensitive, there is no zero.
   

Topic review - Are packages like C structs?
Author Message
  Post subject:  Re: packages are not like C structs  Reply with quote
packages are not like C structs, more like a C++ name space.
It should (and is ) used to avoid name collisions between different
libraries (and the Top level).
And, yes, they contain only types which are ring independent.
Ring depended types (like poly) are contain in their base rings,
#which are quite similiar to packages.
Post Posted: Thu May 21, 2009 2:17 pm
  Post subject:  Are packages like C structs?  Reply with quote
It seems like I should be able to treat a package data type like a C struct, but when I return a package from a procedure, I can't access any of its nested identifiers. I've also tried using importfrom(package,identifier), but that doesn't work either. Here's an example.

Code:
> proc gimmePackage()
. {
.    package apack;
.    int apack::anum = 1;
.
.    return(apack);
. }
>
> package testpack = gimmePackage();
> listvar(testpack);
// testpack             [0]  package (N)
// ::anum               [1]  int 1
>
> testpack::anum;
   ? `anum` is undefined
   ? error occurred in STDIN line 95: `testpack::anum;`
>
> importfrom(testpack,anum);
   ? `anum` not found in `testpack`
   ? error occurred in STDIN line 96: `importfrom(testpack,anum);`
>
> importfrom(testpack,::anum);
   ? error occurred in STDIN line 97: `importfrom(testpack,::anum);`
   ? last reserved name was `importfrom`
   skipping text from `anum` error at token `)`
>
> importfrom(testpack,testpack::anum);
   ? `anum` not found in `testpack`
   ? error occurred in STDIN line 98: `importfrom(testpack,testpack::anum);`


It also seems that poly data types can't be stored in (user-defined) packages. Is that correct?

Any help is greatly appreciated!
Post Posted: Sun Apr 12, 2009 11:10 pm


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