Quoting constructs: Difference between revisions

J
(Quoting constructs en FreeBASIC)
(J)
Line 182:
There are 3 quoting constructs in Go.
</pre>
 
=={{header|J}}==
 
J provides four mechanisms for inline data:
 
* A sequence of numbers, for example <tt>1 2 3</tt>
* A sequence of characters, for example <tt>'1 2 3'</tt>
* A newline terminated multiline script, for example: <lang J>0 :0
1 2 3
4 5 6
)</lang>
* (in recent J versions), an embeddable newline terminated multiline script, for example: <lang J>{{)n
1 2 3
4 5 6
}}</lang>
 
Sequences of numbers or characters which contain exactly one element are treated specially -- they do not have a length of their own.
 
J also has a constant language for numbers, which gives special significance to embedded letters. For example <tt>12e3</tt> is the floating point value 12000 (but J extends this notation to support some numbers in bases other than 10, extended precision integers, rational values and complex values).
 
The multiline scripts are special cases of the mechanisms for defining verbs, adverbs and conjunctions (what might be called functions or macros or operators or procedures in other languages) which instead provide the raw characters of the definition. The old form (beginning with <tt>0 : 0</tt> and ending with a line containing a single right parenthesis and no other displayable characters) is different from the new form (beginning with <tt>{{)n</tt> and ending with a line which has <tt>}}</tt> and no other characters preceding it) in the way that any following part of a surrounding sentence is arranged. These values of <tt>A</tt> would be equivalent:
 
<lang J>NB. no trailing linefeed
A=: '1 2 3'
 
NB. removing linefeed
A=: 0 : 0-.LF
1 2 3
)
 
NB. removing linefeed
A=: {{)n
1 2 3
}}-.LF</lang>
 
Also, the <nowiki>{{}}</nowiki> forms are nestable. So, for example, this would also define an equivalent value for <tt>A</tt>:
 
<lang J>{{
{{
A=: {{)n
1 2 3
}}-.LF
}}''
}}''</lang>
 
The use of an unbalanced right parenthesis as an escape character was inherited from APL. The double curly brace mechanism was a compromise between J's existing use of curly braces and visual conventions used in a variety of other languages.
 
=={{header|jq}}==
6,951

edits