Skip to content

Make use of mapslices consistent throughout Julia #3893

@johnmyleswhite

Description

@johnmyleswhite

I'd like to propose the radical, breaking change of removing all forms of implicit mapslices calls from Julia. I think they make the language much less consistent and create a situation in which one's expectations are routinely violated about the interface for functions. As an example, the list below shows some functions that effectively implement implicit calls to mapslices:

  • sum
  • prod
  • mean
  • var
  • std

In contrast, the following similar functions do not support the foo(A, dim) interface at all:

  • median
  • quantile
  • indmax / indmin
  • findmax / findmin
  • Everything defined in the Stats module

I understand that this change would break a great deal of Matlab compatibility and make the language a little more verbose. But I think the gains in consistency would more than make up for that loss by making the language much less confusing. Removing this shorthand would mean that you wouldn't have to memorize which functions belong to a privileged subset that perform implicit mapslices.

As one example of the memorization required to use the foo(A, dim) interface, you need to memorize that empty tuples passed to min are required to trick min into creating slices. I'd much rather know that mapsplices works the same way for all functions in the language.

Metadata

Metadata

Assignees

Labels

breakingThis change will break codefoldsum, maximum, reduce, foldl, etc.needs decisionA decision on this change is needed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions