Design #476
Review utility of package IO
Description
Package io
does not do much currently; can we eliminate it?
History
#1 Updated by Anna Maria Bigatti about 10 years ago
- Target version set to CoCoA-5.1.0 Easter14
#2 Updated by John Abbott about 10 years ago
- Target version changed from CoCoA-5.1.0 Easter14 to CoCoA-5.1.1 Seoul14
#3 Updated by Anna Maria Bigatti almost 10 years ago
- % Done changed from 0 to 10
At the moment it is only exporting format
(which I find quite useful).
I updated Format/format
and checked the manual.
Another function defined there is StarPrintFold
: now StarPrint
is no longer needed, but the Fold
part can still be useful.
#4 Updated by Anna Maria Bigatti over 9 years ago
- Assignee set to Anna Maria Bigatti
- Priority changed from Normal to Low
- Target version changed from CoCoA-5.1.1 Seoul14 to CoCoA-5.?.?
I don't think we should eliminate it.
In time, we can see what can be useful and advertized (low priority)
#5 Updated by John Abbott over 6 years ago
- Status changed from New to In Progress
Indeed some form of "folded" printing could be useful for large outputs (especially inside emacs which has problems with long lines).
Currently StarPrintFold
does not work, but the manual suggests that it should work.
Anna correctly points out that the fn is not exported from the package, but attempting to call StarPrintFold
does indeed produce the suggestion to use the name $io.StarPrintFold
It should not be too hard to revise the package so that StarPrintFold
works. I wonder what the name of the fn should be; the Star
part is no longer necessary.
#6 Updated by John Abbott about 5 years ago
- Target version changed from CoCoA-5.?.? to CoCoA-5.3.0
JAA thinks we can remove StarPrint
and StarPrintFold
from the CoCoA-5 manual (and also from io.cpkg5
)
It might be useful to have a fold
function for a string: it would take a string and a width, and then
print out the string trying not to exceed the given width (I'm not yet clear what the semantics should be).
#7 Updated by Anna Maria Bigatti about 5 years ago
John Abbott wrote:
JAA thinks we can remove
StarPrint
andStarPrintFold
from the CoCoA-5 manual (and also fromio.cpkg5
)It might be useful to have a
fold
function for a string: it would take a string and a width, and then
print out the string trying not to exceed the given width (I'm not yet clear what the semantics should be).
I agree.
Indeed StarPrint
appears as "not yet implemented", so we could just remove it.
And I also agree that the fold
function could be useful.
I'll have a look.
#8 Updated by John Abbott about 5 years ago
fold
:
- it seems there are three similar utilities:
fold
which inserts newlines after everyK
characters,fmt
which inserts newlines next to whitespace, andpar
which is purportedly "smarter" thanfmt
- at the moment my preference is for a function which takes a string and returns a string (rather than a procedure which takes a string and prints directly); a user who calls the function at top-level will probably not notice a difference (unless the string is very long).
I think it may be reasonable to offer two functions: one like fold
(simple, easy to understand, but may insert newlines in "funny places"), and one like fmt
(or par
) which inserts newlines only in "nice" places (e.g. next to whitespace). The latter function might be useful for printing out large polynomials in a slightly more readable way (but who want to read such a large poly anyway?)
- perhaps with an extra parameter saying what strategy to use for inserting spaces?
- perhaps it works like
fold
if the arg is a string, and works likefmt
if the arg is ringelem (or list or matrix or ???)
#9 Updated by John Abbott about 5 years ago
What about the other junk in io.cpkg
?
format
is exportedSprintTrunc
appears in the CoCoA-5 manual, but it is not exported, and does not seem to be used in any package... Delete it?Print_Aliases
is obsolete?Print_Table
seems like a nice function (but old-fashioned name)Print_Matrix
looks dodgy to meTagged
!! shouldn't this give a syntax error?
#10 Updated by Anna Maria Bigatti about 5 years ago
- % Done changed from 10 to 30
John Abbott wrote:
What about the other junk in
io.cpkg
?
format
is exported
and is used
SprintTrunc
appears in the CoCoA-5 manual, but it is no exported, and does not seem to be used in any package... Delete it?
In the manual, but "NOT YET IMPLEMENTED", and indeed does not work.
Print_Aliases
is obsolete?
I'd say yes.
Print_Table
seems like a nice function (but old-fashioned name)
We wrote a PrintTable
for a matrix in experimental.cpkg.
Should we move it to io.cpkg5? to mat.cpkg5?
/**/ PrintTable(StdDegRevLexMat(4)); /**/ PrintTable(StdDegRevLexMat(4), 1);
Print_Matrix
looks dodgy to me
I agree, and the new one is more flexible.
Tagged
!! shouldn't this give a syntax error?
no, it is not exported.
(that was our choice in the cocoa5 language for making packages less painful than cocoa4).
This was common in packages with tags to avoid overwriting them.
Pointless now, as we changed the printing philosophy (see PrintRes, PrintBettiMatrix,..).
Instead, if you think of the recursion, it does say "Too many nested scopes" (after fixing other things)
#11 Updated by John Abbott over 4 years ago
- Target version changed from CoCoA-5.3.0 to CoCoA-5.4.0
If the package exports only format
, perhaps that package name should be changed to format
?
#12 Updated by John Abbott about 4 years ago
- % Done changed from 30 to 40
I have implemented a fold
function in CoCoALib, and exported it to CoCoA-5.
I have not implemented a "smart" fold fn; it would be considerably more complicated, and I'm not sure it would really be that much more useful.
#13 Updated by John Abbott about 2 years ago
- Target version changed from CoCoA-5.4.0 to CoCoA-5.4.2