Feature: Function Definition Statements #12

Closed
opened 2023-10-17 05:06:21 +00:00 by j · 1 comment
Owner

Feature Progress

  • Define function definition syntax
  • Implement AST nodes corresponding to that syntax
  • Decide if (and how) to support variadic arguments.
    • VA_LIST is kinda bad, but understandable.
  • Implement parser rules for new AST nodes
  • Write tests for new parser rules

Feature description

A function declaration adds a function definition into the local scope. The main function is run after the program starts, and exiting main causes the program to shut down. Other functions will eventually be callable using a Function Call.

Example

fn main (arg1: Type1, arg2: Type2, arg3: Type3, [...]) -> ReturnType { 
    /* Expr | Empty */ 
}
# Feature Progress <!-- Describe the steps for implementing this feature in libconlang --> - [x] Define function definition syntax - [x] Implement AST nodes corresponding to that syntax - [x] Decide if (and how) to support variadic arguments. - VA_LIST is kinda bad, but understandable. - [x] Implement parser rules for new AST nodes - [ ] Write tests for new parser rules # Feature description <!-- [Feature name] does a cool thing that you should describe here --> A function declaration adds a function definition into the local scope. The `main` function is run after the program starts, and exiting `main` causes the program to shut down. Other functions will eventually be callable using a Function Call. # Example <!-- Demonstrate this feature with a clear, concise code example Right now, we're (ab)using Rust syntax highlighting, since it most closely matches what I'm currently aiming for --> ```rust fn main (arg1: Type1, arg2: Type2, arg3: Type3, [...]) -> ReturnType { /* Expr | Empty */ } ```
j added the
enhancement
label 2023-10-17 05:06:21 +00:00
j self-assigned this 2023-10-17 05:06:21 +00:00
j added this to the Basic Syntax project 2023-10-17 05:06:21 +00:00
j changed title from Feature: Function Definition Expressions to Feature: Function Definition Statements 2023-10-24 01:15:23 +00:00
Author
Owner

I've decided to leave variadics off. As of right now, the perma-unstable builtin system allows them, but all native Conlang functions have a fixed number of arguments.

I've decided to leave variadics off. As of right now, the perma-unstable `builtin` system allows them, but all native Conlang functions have a fixed number of arguments.
j closed this issue 2023-10-30 05:23:51 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: j/Conlang#12
No description provided.