ThisClass thisVariable = null
The above is "obvious", as is the below:
this_class this_variable = null
However what is
this class this variable = null
Is it a variable named "variable" of type "this class this"? Is it a variable named "this variable" of type "this class"? Is it a variable named "class this variable" of type "this"?
These are false time savers. We’re writing code, just recognize that and do what’s natural, snake_case. Any conventions to make code “more readable” to make it like written language seem like fool’s errands to me.
var initial factory = abstract configuration factory factory. configure new factory() var search result = users. find all by name (name);
if (search result. is present()) {
return ok(search result. get());
} else return not found();
It’s weird and syntax highlighting is absolutely necessary to read this. search result := users @ find all by name (name)
if search result @ is present() {
return ok(search result @ get())
} else {
return not found()
} search result := users, find all by name (name)
if search result, is present() {
return ok(search result, get())
} else {
return not found()
} // comma is optional, used for disambiguation
search result := users, find all by name. // omitted parameters match words
if search result is present, // empty brackets can be omitted
return ok(search result value); // API change for better readability
else
return: not found. // colon is another optional delimiter
I actually like it so much, I would try to write a transpiler to Java… PS> ${Valid characters for an identifier? Eh, ¯\_(ツ)_/¯ whatever (`}) you want.} = $True
PS> ${Valid characters for an identifier? Eh, ¯\_(ツ)_/¯ whatever (`}) you want.}
True
Jesting aside, I have actually used that syntax before to prefix variable names with '&' and '@' to differentiate between virtual and physical addresses in some code for patching a binary.The first restriction might make this a problem. I am not saying it is a good idea, but it is not obvious to me.
foo and bar == true
means foo && bar == true
or foo_and_bar == true
?You could fix it with ugliness like making the keyword `@and` or some such, or the variable `foo @and bar` but that's not an improvement.
Like I said, I can’t picture the requirement, but am not sure it is a good idea.
DO 10 I = 1.100
as DO10I = 1.1
and DO 10 I = 1,100
as the beginning of a loop ;)I've never written a compiler, but I don't see how the last lines are harder to parse:
if ( thisLooksAppealing )
{
youLikeCamelCase = true;
votePoll( camelCaseFormatting );
}
else if ( this_looks_appealing )
{
you_like_underscores = true;
vote_poll( underscore_formatting );
}
else if ( this looks appealing )
{
you like spaces = true;
vote poll ( space formatting );
}You have to be careful with infix operators, but there is always Haskell's solution of adding backticks for infix names.
So add(a, b) is the same as a `add` b
But without joking, a _real_ solution to infix operator names would be a backslash as prefix, as pseudo-Latex-style, so a \add b
That's not a problem at all, as long a a newline isn't treated as space and you don't use ML style function application, where a space is used to separate the argument(s) from the function name - `f x` instead of `f(x)`.
Note: this is not a good idea