Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Asterisk
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
====Programming languages==== Many [[programming language]]s and [[calculator]]s use the asterisk as a symbol for [[multiplication]]. It also has a number of special meanings in specific languages, for instance: * In some languages such as [[C (programming language)|C]], [[C++]], and [[Go (programming language)|Go]], the asterisk is used to [[dereference]] or declare a [[pointer (computer programming)|pointer]] variable. * In [[Common Lisp]], the names of [[global variable]]s are conventionally set off with asterisks, <code>*LIKE-THIS*</code>. * In the [[Ada (programming language)|Ada]], [[Fortran]], [[Perl]], [[Python (programming language)|Python]], [[Ruby (programming language)|Ruby]], some dialects of [[Pascal programming language|Pascal]], and many others, a double asterisk is used to signify [[exponentiation]]: <code>5**3</code> is 5<sup>3</sup> = 125. * In [[Perl]], the asterisk is used to refer to the ''[[typeglob]]'' of all variables with a given name. * In [[Ruby (programming language)|Ruby]] and [[Python (programming language)|Python]], the asterisk has two specific uses. First, the unary * operator applied to a list object inside a function call will expand that list into the positional arguments of the function call. Second, a parameter preceded by * {{anchor|args}}in the parameter list in a function definition will result in any extra positional parameters being aggregated into a [[tuple]] (Python) or [[array data type|array]] (Ruby), and likewise a parameter preceded by ** {{Anchor|kwargs}} will result in any extra [[named parameter|keyword parameters]] being aggregated into a [[associative array|dictionary]] (Python) or [[associative array|hash]] (Ruby): <syntaxhighlight lang="python">def function1(a, b, c, d): print(a, b, c, d) def function2(first, *args): # args will be a tuple # the name 'args' is convention: it may be any parameter name print(args) def function3(first, **kwargs): # kwargs will be a dict # the name 'kwargs' is convention: it may be any parameter name print(kwargs) function1(1, 2, 3, 4) # prints 1 2 3 4 function1(*[1, 2, 3, 4]) # prints 1 2 3 4 function1(**{"a": 5, "b": 6, "c": 7, "d": 8}) # prints 5 6 7 8 function2(1, 2, 3, 4) # prints (2, 3, 4), 1 is not part of args function2(99) # prints (), unfilled *parameter will be () function3(0, e=3, f=9) # prints {'e': 3, 'f': 9}, 0 is not part of kwargs function3(0) # prints {}, unfilled **parameter will be {}</syntaxhighlight> * In [[APL (programming language)|APL]], the asterisk represents the [[Exponential function|exponential]] and [[exponentiation]] functions, with <code>*X</code> representing <var>e</var><sup><var>X</var></sup>, and <code>Y*X</code> representing <var>Y</var><sup><var>X</var></sup>. * In IBM [[Job Control Language]], the asterisk has various functions, including in-stream data in the DD statement, the default print stream as <code>SYSOUT=*</code>, and as a self-reference in place of a procedure step name to refer to the same procedure step where it appears. * In [[Haskell (programming language)|Haskell]], the asterisk represents the set of well-formed, fully applied types; that is, a 0-ary ''kind'' of types. =====Comments in programming languages===== {{Main article|block comments}} In the [[B (programming language)|B programming language]] and languages that borrow syntax from it, such as [[C (programming language)|C]], [[PHP]], [[Java (software platform)|Java]], or [[C Sharp (programming language)|C#]], comments in the [[source code]] (for information to people, ignored by the [[compiler]]) are marked by an asterisk combined with the slash: <syntaxhighlight lang="c#"> /* This section displays message if user input was not valid (comment ignored by compiler) */ </syntaxhighlight> [[CSS]] also uses this comment format:<syntaxhighlight lang="css"> body { /* This ought to make the text more readable for far-sighted people */ font-size: 24pt; } </syntaxhighlight> Some [[Pascal (programming language)|Pascal]]-like programming languages, such as [[Object Pascal]], [[Modula-2]], [[Modula-3]], and [[Oberon (programming language)|Oberon]], and other languages such as [[ML (programming language)|ML]], [[Wolfram Language]] ([[Mathematica]]), [[AppleScript]], [[OCaml]], [[Standard ML]], and [[Maple (software)|Maple]], use an asterisk combined with a parenthesis: <syntaxhighlight lang="Applescript"> (* Do not change this variable - it is used later (comment ignored by compiler) *) </syntaxhighlight> Each computing language has its own way of handling comments; {{code|/* ... */}} and similar notations are not universal.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Asterisk
(section)
Add topic