Project

General

Profile

Feature #346

Describe should indicate package name

Added by John Abbott almost 11 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Normal
Category:
Parser/Interpreter
Target version:
Start date:
29 Apr 2013
Due date:
% Done:

100%

Estimated time:
2.22 h
Spent time:

Description

The describe command will produce the source code of a package function, but it does not indicate the package the function comes from. It should indicate the package (perhaps simply as a comment, so the source code produced remains fairly valid).

Try the following:

describe BinExp;

2021-01 Describe cannot know the package name (see #10), so added functions and suggestions when calling describe for a user defined function


Related issues

Related to CoCoA-5 - Support #208: describe $packageClosed2012-07-11

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

Related to CoCoA-5 - Feature #1174: package of a function --> of an identifier!Closed2018-04-05

Related to CoCoA-5 - Design #1546: Improve 'describe' or 'print' for a functionClosed2020-12-04

History

#1 Updated by John Abbott about 10 years ago

The relevant source code appears to be in Interpreter.C:229:

void UserDefinedFunction::describe(intrusive_ptr<OutputStreamValue> out) const...

#2 Updated by John Abbott about 10 years ago

Packages export their varables in the function:

void PackageStatement::implExecute(RuntimeEnvironment *runtimeEnv)

in file Interpreter.C:3885

The relevant code appears to be in lines 3939-3948, though I'm not sure I understand it all.

#3 Updated by John Abbott about 10 years ago

A possibly simpler solution to the problem would be to have a function PackageOf which says which package protected a package-protected variable. The result would presumably be a string.

#4 Updated by Anna Maria Bigatti almost 10 years ago

  • Target version set to CoCoA-5.1.0 Easter14

#5 Updated by John Abbott almost 10 years ago

  • Target version changed from CoCoA-5.1.0 Easter14 to CoCoA-5.?.?

#6 Updated by John Abbott almost 6 years ago

  • Related to Feature #1174: package of a function --> of an identifier! added

#7 Updated by John Abbott almost 6 years ago

The CoCoA fn Starting says when a symbol comes from a package, and which package it comes from, so describe should be able to do it too! Investigate!

#8 Updated by Anna Maria Bigatti over 3 years ago

  • Related to Design #1546: Improve 'describe' or 'print' for a function added

#9 Updated by John Abbott about 3 years ago

Since Anna seems to have solved issue #1174, is it now possible to make progress here?

Since normal printing now produces the source code of a CoCoA function, what should describe do when given a package-exported variable?
Does describe operate with the variable or on the value of the variable... or both?

#10 Updated by John Abbott about 3 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 60
IMPORTANT
  • the describe command describes a value and not a variable;
  • a fn defn does not contain any information about which package the defn was in;
  • the package info is associated with the protected top-level variable created by an export command.

Given this situation it is impossible for describe know the package (since it evaluates its argument).

#11 Updated by John Abbott about 3 years ago

Since print and sprint now produce the body of a CoCoA-5 function, it superfluous for describe to do the same.

SUGGESTION:
when describe applied to a function it can produce a succinct description similar to what print used to produce e.g. <built-in function> and <user-defined function>

Note: if a fn "knows" whether it was defined in a package, it might be possible to have also <package-defined function>

JAA is hoping Anna will modify the impl of describe to behave as suggested here (we did agree on this during today's call).

#12 Updated by John Abbott about 3 years ago

  • Target version changed from CoCoA-5.?.? to CoCoA-5.4.0

#13 Updated by Anna Maria Bigatti about 3 years ago

  • Description updated (diff)
  • Status changed from Resolved to Feedback
  • Assignee set to Anna Maria Bigatti
  • % Done changed from 60 to 90

#14 Updated by John Abbott about 3 years ago

  • Description updated (diff)
  • Status changed from Feedback to Closed
  • % Done changed from 90 to 100
  • Estimated time set to 2.22 h

As reported in comment 10, the original request cannot be fulfilled -- instead use new fn PackageOf, see issue #1174.

Also available in: Atom PDF