Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
byte32817yIt did get better from "public static void main() {}"
To "pub fn main() {}" Or "pub fn foo() i32 {}"
Welcome to devRant!!! -
Then we got python
def myFunc:
Note how the term "function" is not used here at all xP -
Cliff122707yAlso JS:
() => {}
Even cleaner if you have one argument and the function only consists of a return statement:
x => x * 2 -
hell165967ypublic static void main()
1 2 3 4
1- Access permission/visibility
2- Static means not being tied to an object instantiation, its a class method rather than an object method.
3- Return type
4- method name
Not a single wasted "function/fun/fn/def" or whatever ....
@byte -
Root797347y@IllSlapU Mismatched and clashing colors, patterns, and fabrics is a "style," too, I suppose. Both evoke eye-bleeding, and for the same reasons.
-
byte32817y@azous I don't do OOP regularly now a days, and the languages I use have a unique way of implementing it.
I was giving my example for Go and Rust as they have a new syntax style and I've used these languages.
So 'static' might not be used, but Go syntax allows to join function to structs as methodes
Eg: func (a *aStruct) method() {}
Or Rust:
impl a_struct A{
pub fn method() {}
}
And as there is no proper concept of class no need to specify static, just add them to the package/module and they are 'static' as per OOP definition.
The 'pub' in Rust is the same as access and everything else is private by default
Go does it by syntax, functions starting with caps are public all other private
The name is present in all cases
The return type is written after the function name and no need to specify 'void' type
Go: func getInt() int {}
Rust: fn getInt() i32 {} -
Root797347y@Pogromist depends on the assembler.
I've used some whose labels were prefixed with a bang.
Related Rants
Function definition in various programming languages
//JavaScript/PHP
function myfunc()
{
}
//Swift
func myfunc()
{
}
//Kotlin
fun myfunc()
{
}
//Rust
fn myfunc()
{
}
//Next...
f myfunc()
{
}
undefined
swift
kotlin
php
js
rust