5

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.

  • 3
    I have been using this notation for years. funcion[] is just a way to indicate that function 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 as func(), omitting arguments, even when they do have a number of arguments. But many Mma users don't use C. – Szabolcs Apr 8 '13 at 13:27
  • I don't really have a point with these comments. It just never occurred to me that anything would be wrong with writing func[] and I explained why I was doing this. – Szabolcs Apr 8 '13 at 13:30
  • @Szabolcs I did not realize your hand behind these, more likely new users used the bracket form in their posts. While I agree with you (and with @Mr.Wizard) that it doesn't really matter on the global scale, I still feel it seems more "professional" (?) if we use a uniform style and omit []. And also, nothing really happened here in meta for 2 days now... – István Zachar Apr 8 '13 at 14:12
  • 2
    I use this style for the same reason as Szabolcs; it's a tic I have from the use of other programming languages. To be honest, this sounds like a somewhat "religious" matter to me... also, I don't expect that when I write "that's how Sin[] works", some other user will select and copy the Sin[] for execution into Mathematica. – J. M. will be back soon Apr 9 '13 at 13:49
  • 1
    In my opinion, it depends on whether the function name appears as part of a code snippet that's meant to be syntactically valid, or as part of a natural-language sentence, or in "pseudo-code". For the latter two, I don't think there's any harm in writing func[] if it's clear from the context what you're referring to. – Jens Apr 13 '13 at 2:46
  • 1
    @Jens As always, it may be fine in moderation (although I personally dislike using []), but some take it to extremes and you end up seeing stuff like "You can use Show[] to combine the Plot[] of Sin[] and Cos[] and Export[] it...". – rm -rf Apr 13 '13 at 18:49
14

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 that Dot should use arguments, but more experienced Mathematica-users know that there are commands that work without arguments (like Notebooks[]). 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.

  • 3
    I 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. – Mr.Wizard Apr 8 '13 at 13:23
  • 1
    I 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. – m_goldberg Apr 9 '13 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.) – Oleksandr R. Apr 9 '13 at 7:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .