Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax: define a function #5

Closed
fly-lang opened this issue Feb 7, 2021 · 3 comments
Closed

Syntax: define a function #5

fly-lang opened this issue Feb 7, 2021 · 3 comments
Labels
good first issue Good for newcomers planning For project plan tracking

Comments

@fly-lang
Copy link
Owner

fly-lang commented Feb 7, 2021

Create the Fly syntax for defining a function

Following different examples from known languages, chose the best syntax (combination permitted) by considering the most readable solution. You can also make a different proposal.

Python

def printme( str ):
   print str
   return true

Rust

fn printme(str: String) -> bool {
    println!(str);
    return true;
}

C/C++

bool printme(char str*) {
  cout << str;
  return true;
}

Javascript

function printme(str) {
  alert(str)
  return true;
}

Go

func printme(str string) bool {
  fmt.Println(str)
  return true
}
@fly-lang fly-lang added the good first issue Good for newcomers label Feb 7, 2021
@fly-lang fly-lang added this to the Fly Language Syntax milestone Feb 7, 2021
@fly-lang fly-lang added the planning For project plan tracking label Feb 11, 2021
@MattKotzbauer
Copy link

C++'s syntax looks the best if you want to declare the type that's going to be returned; it just seems kinda intuitive to declare the premises/return type of the function at first with the input then coming inside of parentheses. Otherwise, Js seems the most intuitive because it says it's a function, does the same thing with the parentheses and input, and keeps it more flexible. idk

@fly-lang
Copy link
Owner Author

C++'s syntax looks the best if you want to declare the type that's going to be returned; it just seems kinda intuitive to declare the premises/return type of the function at first with the input then coming inside of parentheses. Otherwise, Js seems the most intuitive because it says it's a function, does the same thing with the parentheses and input, and keeps it more flexible. idk

So static typing like c++ with function keyword, looks a bit like Rust and Go but in common way:

function bool printme(char str*) {
  cout << str;
  return true;
}

@fly-lang
Copy link
Owner Author

Function definition:

bool printme(char str*) {
  cout << str;
  return true;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers planning For project plan tracking
Projects
None yet
Development

No branches or pull requests

2 participants