Ellipsis (computer programming): Difference between revisions

Content deleted Content added
Citation bot (talk | contribs)
Add: title. Changed bare reference to CS1/2. | Use this bot. Report bugs. | Suggested by BrownHairedGirl | Linked from User:BrownHairedGirl/Articles_with_bare_links | #UCB_webform_linked 1161/2847
improved refs
Line 1:
{{more citations needed|date=September 2014}}
{{use dmy dates|date=June 2022|cs1-dates=y}}
In [[computer programming]], '''ellipsis''' notation (.. or ...) is used to denote [[range (computer programming)|ranges]], an unspecified number of arguments, or a parent directory. Most programming languages require the [[ellipsis]] to be written as a series of periods; a single ([[Unicode]]) ellipsis character cannot be used.
 
Line 9 ⟶ 10:
In Ruby the <code>...</code> operator denotes a half-open range, i.e. that includes the start value but not the end value.
 
In [[Rust (programming language)|Rust]] the <code>..=</code> operator denotes an inclusive range for cases in matches and the <code>..</code> operator represents a range not including the end value.
 
Perl and Ruby [[Operator overloading|overload]] the ".." operator in scalar context as a [[flip-flop operator]] - a [[stateful]] [[bistability|bistable]] [[Boolean datatype|Boolean]] test, roughly equivalent to "true while ''x'' but not yet ''y''", similarly to the "," operator in [[Sed (programming language)|sed]] and [[AWK programming language|AWK]].<ref>[http://perldoc.perl.org/perlop.html#Range-Operators-operator%2c-range-range-..-... perlop - perldoc.perl.org<!-- Bot generated title -->]</ref>
Line 40 ⟶ 41:
 
== Incomplete code ==
In Perl<ref>{{Cite web | url=https://perldoc.perl.org/perlsyn.html#The-Ellipsis-Statement | title=Perlsyn - Perl syntax - Perldoc Browser }}</ref> and [[Raku (programming language)|Raku]]<ref>{{Cite web | url=https://doc.perl6.org/language/operators#listop_... | title=Operators }}</ref> the 3-character ellipsis is also known as the "yada yada yada" operator and, similarly to its [[linguistic meaning]], serves as a "stand-in" for code to be inserted later.
 
[[Python3]] also allows the 3-character ellipsis to be used as an expressive place-holder for code to be inserted later.
Line 49 ⟶ 50:
In the [[C (programming language)|C programming language]], an ellipsis is used to represent a [[variadic function|variable number of parameters]] to a [[function (programming)|function]]. For example:
 
:{{code|2=c|int printf( const char* format, ... );}}<ref>{{Cite web | url=http://www.cplusplus.com/reference/cstdio/printf/ | title=Printf - C++ Reference }}</ref>
 
The above function in C could then be called with different types and numbers of parameters such as:
Line 59 ⟶ 60:
[[C99]] introduced macros with a [[variadic macro|variable number of arguments]].<ref>[https://gcc.gnu.org/onlinedocs/gcc/Variadic-Macros.html Variadic Macros - Using the GNU Compiler Collection (GCC)]</ref>
 
[[C++11]] included the C99 preprocessor,<ref>Working draft changes for C99 preprocessor synchronization - http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1653.htm</ref> and also introduced templates with a [[variadic template|variable number of arguments]].<ref>{{cite web | title=Working Draft, Standard for Programming Language C++ | url=http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3337.pdf}}: 14.5.3 Variadic templates</ref>
 
===Java===
Line 68 ⟶ 69:
===PHP===
 
PHP 5.6 supports<ref>{{Cite web | url=https://wiki.php.net/rfc/variadics | title=PHP: RFC:variadics }}</ref> use of ellipsis to define an explicitly [[variadic function]], where <code>...</code> before an argument in a function definition means that arguments from that point on will be collected into an array. For example:
 
<syntaxhighlight lang="php">
Line 92 ⟶ 93:
 
== Multiple dimensions ==
In [[Python (programming language)|Python]], particularly in [[NumPy]], an ellipsis is used for slicing an arbitrary number of dimensions for a high-dimensional array:<ref>{{Cite web | url=http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html | title=Indexing routines — NumPy v1.22 Manual }}</ref>
 
<syntaxhighlight lang="pycon">
Line 109 ⟶ 110:
:<code>x = [ 1 2 3 4 5 6 ];</code>
 
In Raku an actual [[Unicode]] (U+2026) ellipsis (…) character is used to serve as a type of marker in a format string.<ref>[{{cite web |title=Exegesis 7: Formats |editor-first=Larry |editor-last=Wall |editor-link=Larry Wall |author-first=Damian |author-last=Conway |author-link=Damian Conway |date=2006-05-29 |orig-date=2004-02-26 |version=2 |number=7 |website=dev.perl.org |url=http://dev.perl.org/perl6/doc/design/exe/E07.html#And_mark_what_way_I_make... Exegesis 7: Formats |url-status=dead perl6<!-- Bot generated title -|archive->] {{Webarchive|url=https://web.archive.org/web/20110615080653/http://dev.perl.org/perl6/doc/design/exe/E07.html#And_mark_what_way_I_make... |archive-date=2011-06-15 }}</ref>{{Self-published inline|date=January 2011}}
 
==References==