Project

General

Profile

Feature #1174

package of a function --> of an identifier!

Added by Elisa Palezzato about 6 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
High
Category:
CoCoA-5 function: new
Target version:
Start date:
05 Apr 2018
Due date:
% Done:

100%

Estimated time:
Spent time:

Description

How to have a function that says in which package is in the input?
Why does not describe have this feature?!

2021-01 PackageOf("<name>");
describe cannot know the package, because it receives the evaluated object, and not its name/identifier.


Related issues

Related to CoCoA-5 - Feature #346: Describe should indicate package nameClosed2013-04-29

Related to CoCoA-5 - Bug #1200: Package exported function: wrong package nameClosed2018-07-27

Related to CoCoA-5 - Feature #531: Package protected variables should know which package protected themClosed2014-04-09

History

#1 Updated by John Abbott about 6 years ago

  • Related to Feature #346: Describe should indicate package name added

#2 Updated by Anna Maria Bigatti over 5 years ago

  • Category set to CoCoA-5 function: new
  • Assignee set to Anna Maria Bigatti
  • Target version set to CoCoA-5.2.4

Waiting for a proper implementation in C++, we can do something like starting.

#3 Updated by Anna Maria Bigatti over 5 years ago

  • Related to Bug #1200: Package exported function: wrong package name added

#4 Updated by Anna Maria Bigatti over 5 years ago

  • Target version changed from CoCoA-5.2.4 to CoCoA-5.3.0

#5 Updated by John Abbott over 4 years ago

  • Priority changed from Normal to High
  • Target version changed from CoCoA-5.3.0 to CoCoA-5.4.0

#6 Updated by John Abbott about 4 years ago

As Anna said in comment 2: the function starting is able to get the information. So we should look there to see how to do it.

#7 Updated by John Abbott over 3 years ago

Anna has a prototype in coclib.cpkg5. Currently commented out -- how long has it been there??

If it were built-in then it could be used by describe.

#8 Updated by Anna Maria Bigatti over 3 years ago

  • Status changed from New to In Progress
  • % Done changed from 0 to 50

#9 Updated by Anna Maria Bigatti over 3 years ago

  • % Done changed from 50 to 60

should the name be PackageOf?

I have investigated: belonging to a package (variable) is a property of the variable (VariableSlot), not of the value of the variable.

Now I have written a function in Interpreter.C taking a string (the variable name).

There was a function called findOwner (now FindOwnerPkg) in Interpreter.C in anonymous name space. I used it.

Can I make PackageOf take a variable? will see

#10 Updated by Anna Maria Bigatti over 3 years ago

  • Related to Feature #531: Package protected variables should know which package protected them added

#11 Updated by Anna Maria Bigatti over 3 years ago

Example:

/**/ anna := starting;
/**/ PackageOf("starting");
$coclib
/**/ PackageOf("anna");
<not in a package>

So, to have it working with the variable, not the string with the variable name, the argument should not be evaluated, as it happens for IsDefined (only case like that)

#12 Updated by John Abbott over 3 years ago

Well done! I suggest we accept the version taking a string for the time being (unless you can easily make a fn like IsDefined).

When exactly is it useful to find the package? I think I use it only when debugging (or perhaps if the documentation seems unclear, and I want to see what the code actually does).

Other things which do not evaluate a variable are: describe, (un)protect.

#13 Updated by Anna Maria Bigatti over 3 years ago

  • Subject changed from package of a function to package of a function --> of an identifier!

#14 Updated by Anna Maria Bigatti about 3 years ago

  • Description updated (diff)
  • Status changed from In Progress to Feedback
  • % Done changed from 60 to 90

I'm now convinced that the only exception to the evaluation of the argument of a function should be IsDefined. There is no point in making an exception for such a small function as PackageOf.

So, in conclusion, the only great advantage of PackageOf vs starting is the good name ;-)
It is also faster, but it's pretty irrelevant for its tipical use (i.e. not within loops).

#15 Updated by Anna Maria Bigatti about 3 years ago

  • Status changed from Feedback to Closed
  • % Done changed from 90 to 100

Also available in: Atom PDF