You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is very common to format source code as follows:
(* In ML languages with space separated "arguments" *)
let result = myFunction x y {
key1= 'long';
key2='long';
}
// In JS style languages with parenthesis-wrapped comma-delimited arguments
var result = myFunction (x, y, {
key1: 'long',
key2: 'long'
});
It's even difficult for me to articulate exactly when this is the preferred formatting but I'll try:
The entire line will not fit within the allotted space and some line breaking is required.
Having the last argument to a function break into several lines eliminates any need for the //previous// items on the line to have to break onto new lines.
For example, suppose the following samples cannot fit onto a single line. Here are some correct (and incorrect) formatting examples:
(* _Incorrect_ because even after last argument is broken,
the original line is still too long *)
let result = myFunction reallyLongArgument reallyReallyLongArgument {
key1= 'long';
key2='long';
}
(* _Correct_ Every argument would need to be placed on their own lines *)
let result = myFunction
reallyLongArgument
reallyReallyLongArgument
{key1= 'long'; key2='long'}
(* _Incorrect_ because in order to fit the first line, the final
argument had to be place on its own line.
*)
let result = myFunction supposeThisIsReallyLong reallyReallyLongArgument {
key1= 'long';
key2='long';
}
anotherArgument
(* _Correct_ *)
let result = myFunction
supposeThisIsReallyLong
reallyReallyLongArgument
{key1= 'long'; key2='long'}
anotherArgument
(* _Incorrect_ because the last two arguments had to have
their bodies broken up.
*)
let result = myFunction reallyLongArgument reallyReallyLongArgument {
key1= 'long';
key2='long';
} {
key1='long';
key2='long';
}
(* _Correct_*)
let result = myFunction
reallyLongArgument
reallyReallyLongArgument
{key1= 'long'; key2='long'}
{key1='long'; key2='long'}
The text was updated successfully, but these errors were encountered:
It is very common to format source code as follows:
It's even difficult for me to articulate exactly when this is the preferred formatting but I'll try:
For example, suppose the following samples cannot fit onto a single line. Here are some correct (and incorrect) formatting examples:
The text was updated successfully, but these errors were encountered: