Project

General

Profile

Design #1467

Change syntax apply(phi,M) into phi(M)?

Added by John Abbott almost 4 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Improving
Target version:
Start date:
22 Jun 2020
Due date:
% Done:

100%

Estimated time:
2.01 h
Spent time:

Description

Currently to apply a RingHom to the entries of a matrix or a C++ vector we must use the fn apply.

Is it better to use simpler notation where the RingHom can be applied directly: e.g. phi(M) or phi(v)?

Pros and cons? Opinions?

Relevant source file is apply.H


Related issues

Related to CoCoALib - Bug #1601: Compilation ambiguityClosed2021-06-16

Related to CoCoALib - Feature #1598: RingHom: implement phi(X) as apply(phi, X) also for X vector and matrixClosed2021-06-10

Related to CoCoA-5 - Design #1615: apply: remove for RingHomRejected2021-10-04

History

#1 Updated by John Abbott almost 4 years ago

I noticed this while making a prototype impl for automatic ringelem promotion. In particular for ringelem times matrix the code ended up like this
(!!!note!!! the code has changed slightly due to issue #635)

      const RingHom promote = AutomaticConversionHom(Rx,R,"RingElem*Mat");
      if (codomain(promote) == Rx)
        return x * apply(promote,M);
      return promote(x) * M;

It would be slightly neater if I could write promote(M) instead of apply(promote,M).

A feature of writing apply(...) is that it is obvious to the reader that M is not a plain ringelem (but that ought to be clear anyway).

At the moment, it seems to me to be "useless clutter". Some might argue that applying a ringhom directly to a matrix is an "abuse of notation" (but it is also clear, unambiguous and compact...)

NOTE aha! I see that CoCoA-5 wants to use apply when applying a ringhom to MAT, LIST or RINGELEM (why this last one???)

#2 Updated by John Abbott almost 4 years ago

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

We could permit both syntaxes, perhaps making apply(...) obsolescent?
[JAA does not much like having two different but semantically equivalent syntaxes]

Or we could change CoCoA-5 too? Making apply(...) there obsolescent?

Opinions?

#3 Updated by John Abbott almost 4 years ago

  • Description updated (diff)

#4 Updated by John Abbott over 3 years ago

  • Target version changed from CoCoALib-0.99800 to CoCoALib-0.99850

#5 Updated by John Abbott over 2 years ago

  • Related to Bug #1601: Compilation ambiguity added

#6 Updated by John Abbott over 2 years ago

  • Assignee set to John Abbott
  • % Done changed from 10 to 90

In the end my hand was forced.
Some future version of C++ (maybe C++17?) defines a template fn apply which matches better than the CoCoA fns;
there really seemed to be no way to make C++ use the CoCoA fns, so compilation failed. Perhaps the problem could
be resolved using C++20 (with restrictions on when templates will match)? Anyway, not practicable at the moment.

So I have removed apply from CoCoALib, and changed all code which used it.
Everything compiles, and all tests pass.

Moving to "feedback".

#7 Updated by John Abbott about 2 years ago

  • Target version changed from CoCoALib-0.99850 to CoCoALib-0.99800

#8 Updated by Anna Maria Bigatti about 2 years ago

  • Related to Feature #1598: RingHom: implement phi(X) as apply(phi, X) also for X vector and matrix added

#9 Updated by Anna Maria Bigatti about 2 years ago

This issue overlaps with Feature #1598.

#10 Updated by Anna Maria Bigatti about 2 years ago

#11 Updated by Anna Maria Bigatti about 2 years ago

  • Status changed from In Progress to Closed
  • % Done changed from 90 to 100
  • Estimated time set to 2.01 h

Also available in: Atom PDF