Ellipsis (computer programming): Difference between revisions

Content deleted Content added
I got those in the wrong sections, moved the new content to the correct ones.
Line 94:
int(5)
}
</syntaxhighlight>
 
Since PHP 8.1, a nullary ellipsis may be used to create a [[closure (computer programming)|closure]] from a callable or an object method:<ref>{{Cite web |title=PHP 8.1.0 Release Announcement |url=https://www.php.net/releases/8.1/en.php#first_class_callable_syntax |access-date=2023-03-29 |website=php.net}}</ref>
 
<syntaxhighlight lang="php">
// old style: PHP 8.0 and older
$foo = [$this, 'foo'];
$fn = Closure::fromCallable('strlen');
 
// new style: PHP 8.1 and newer
$foo = $this->foo(...);
$fn = strlen(...);
</syntaxhighlight>
 
Line 123 ⟶ 111:
 
== Other semantics ==
 
=== MATLAB ===
In [[MATLAB]], a three-character ellipsis is used to indicate [[line continuation]],<ref>[http://www.mathworks.com/help/techdoc/matlab_env/f0-5789.html#f0-5857 Mathworks.com]</ref> making the sequence of lines
:<code>x = [ 1 2 3 ...<br />4 5 6 ];</code>
Line 129 ⟶ 119:
 
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... |url-status=dead |archive-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>
 
=== PHP ===
 
Since [[PHP]] 8.1, a nullary ellipsis may be used to create a [[closure (computer programming)|closure]] from a callable or an object method:<ref>{{Cite web |title=PHP 8.1.0 Release Announcement |url=https://www.php.net/releases/8.1/en.php#first_class_callable_syntax |access-date=2023-03-29 |website=php.net}}</ref>
 
<syntaxhighlight lang="php">
// old style: PHP 8.0 and older
$foo = [$this, 'foo'];
$fn = Closure::fromCallable('strlen');
 
// new style: PHP 8.1 and newer
$foo = $this->foo(...);
$fn = strlen(...);
</syntaxhighlight>
 
=== Python ===
 
In Python, the ellipsis can also be used as the first parameter within the <code>collections.abc.Callable</code> type annotation to denote any number of arguments:<ref>{{Cite web |title=typing — Support for type hints § typing.Callable |url=https://docs.python.org/3/library/typing.html#typing.Callable |access-date=2023-03-29 |website=Python 3.11.2 Documentation}}</ref>
<!-- typing.Callable is deprecated in favor of collections.abc.Callable, but documentation has not yet been moved! -->
 
<syntaxhighlight lang="python">
from collections.abc import Callable
from typing import TypeAlias, Any
 
VarFunction: TypeAlias = Callable[..., Any]
</syntaxhighlight>
 
==References==