Skip to content

ratplier/stock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stock

stock is a language:

  • Where the code you write says what it means.
  • Where writing code is fast and simple.
  • That is designed to avoid common bugs.

The main ideas of stock:

  1. Performance: you use cool abstractions, you get fast code
  2. Almost no magic: the stock standard library is mostly written in stock
  3. Code that speaks: the language is built for humans first, reading the language must be easy
enum log_level { info, warn, error }
struct player { name: string, health: u32 }

shape debug<T> {
	fn format(&self) -> string
	fn log(&self, level: log_level)
}

impl debug<player> {
	fn format(&self) {
	    `{self.name} [{self.health.to_string()} HP]`
    }
    
	fn log(&self, level: log_level) {
		let formatted_data = data.format()
		let prefix = get_prefix(level)
		
		io::println(`{prefix}: {formatted_data}`)
	}
}

fn main() {
    let player1 = player { name: "hero", health: 85 }
	player1.log(log_level::info); // [info]: hero [85 HP]
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages