Recently I encountered more and more situations where the poster/editor explicitly used function[]
instead of function
when referencing built-in functions (i.e. Dot[]
instead of Dot
). What is the general consensus about these? I only talk about cases where the given function was referenced inline (e.g. in post body or in tag wikis) and not in code.
1 Answer
From some time now I was consistently replacing such bracketed references with non-bracketed ones, because of the following reasons:
- Shorter is better;
- The Online Documentation uses function references without brackets;
- Brackets can be misleading (especially for newcomers), e.g.
Dot[]
in itself doesn't do anything. It might hint thatDot
should use arguments, but more experienced Mathematica-users know that there are commands that work without arguments (likeNotebooks[]
). Some functions even work without the brackets at all. Furthermore,Dot
in itself is correct syntactically. - Majority of references on the site uses the non-bracket version.
- The SE search won't find the bracketed version (see here).
I argue that we should discourage the inclusion of superfluous brackets. Note, that no reference should be changed if the syntax explicitly requires the empty brackets!.
Please vote only if you agree, otherwise post your reasons.
-
3I agree with this, but I would prioritize it only slightly above italicizing Mathematica, and therefore I suppose that it is not appropriate to edit (and bump) old posts solely for this revision. Apr 8, 2013 at 13:23
-
1I always remove [ ] from inline function names when edited a post for other reasons. My main reason for doing so to bring into line with WRI documentation usage. Apr 9, 2013 at 1:29
-
Agree. Notwithstanding that the bracketed form is widely used (especially for other languages), I don't like it. The distinction between "functions" (i.e. down/subvalue rules) and other types of rules is less clear/important in Mathematica, and the brackets are visually/conceptually distracting and do not convey any useful information. I would go far as to say that I think functions of no arguments should normally be implemented as ownvalue rules in code, except in special cases such as when options may need to be passed. (But I am not suggesting that editors amend code to this effect.) Apr 9, 2013 at 7:08
funcion[]
is just a way to indicate thatfunction
is a function, and not something else. I guess it makes more sense in cases where formatting is not available (newsgroups, email, etc.), and this it also indicates that we're talking about code (not just English), e.g. "You can Export[] it." It's a habit I carried over. Regarding the empty brackets, with no arguments, it comes from C where functions can be written asfunc()
, omitting arguments, even when they do have a number of arguments. But many Mma users don't use C.[]
. And also, nothing really happened here in meta for 2 days now...Sin[]
works", some other user will select and copy theSin[]
for execution into Mathematica.func[]
if it's clear from the context what you're referring to.[]
), but some take it to extremes and you end up seeing stuff like "You can useShow[]
to combine thePlot[]
ofSin[]
andCos[]
andExport[]
it...".