Added two more examples about classes and console stuff and some stub code. (0.37.46)
This commit is contained in:
parent
fd582f4d3a
commit
95a0582608
5 changed files with 69 additions and 2 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
cmake_minimum_required(VERSION 3.10)
|
cmake_minimum_required(VERSION 3.10)
|
||||||
project(fun VERSION 0.37.45 LANGUAGES C)
|
project(fun VERSION 0.37.46 LANGUAGES C)
|
||||||
|
|
||||||
set(CMAKE_C_STANDARD 99)
|
set(CMAKE_C_STANDARD 99)
|
||||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||||
|
|
|
||||||
22
examples/class_without_object.fun
Executable file
22
examples/class_without_object.fun
Executable file
|
|
@ -0,0 +1,22 @@
|
||||||
|
#!/usr/bin/env fun
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Fun programming language.
|
||||||
|
* https://fun-lang.xyz/
|
||||||
|
*
|
||||||
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
|
* https://opensource.org/license/apache-2-0
|
||||||
|
*
|
||||||
|
* Added: 2026-01-12
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Demonstrates the usage of functions in classes without initiating an object.
|
||||||
|
|
||||||
|
include <crypt/sha256.fun>
|
||||||
|
|
||||||
|
print(SHA256().sha256_hex(""))
|
||||||
|
|
||||||
|
/* Expected output:
|
||||||
|
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
|
||||||
|
*/
|
||||||
24
examples/console_prompt.fun
Executable file
24
examples/console_prompt.fun
Executable file
|
|
@ -0,0 +1,24 @@
|
||||||
|
#!/usr/bin/env fun
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Fun programming language.
|
||||||
|
* https://fun-lang.xyz/
|
||||||
|
*
|
||||||
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
|
* https://opensource.org/license/apache-2-0
|
||||||
|
*
|
||||||
|
* Added: 2026-01-12
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Demonstrates the the console prompt.
|
||||||
|
|
||||||
|
include <io/console.fun>
|
||||||
|
|
||||||
|
input = Console().prompt("fun> ")
|
||||||
|
print("You entered: " + input)
|
||||||
|
|
||||||
|
/* Possible output:
|
||||||
|
fun> Fun!
|
||||||
|
You entered: Fun!
|
||||||
|
*/
|
||||||
|
|
@ -1,3 +1,12 @@
|
||||||
|
/*
|
||||||
|
* This file is part of the Fun programming language.
|
||||||
|
* https://fun-lang.xyz/
|
||||||
|
*
|
||||||
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
|
* https://opensource.org/license/apache-2-0
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Console utilities: prompt, ask, and yes/no helpers built on input().
|
* Console utilities: prompt, ask, and yes/no helpers built on input().
|
||||||
*/
|
*/
|
||||||
|
|
@ -38,3 +47,6 @@ class Console()
|
||||||
else if (a == "n" || a == "no")
|
else if (a == "n" || a == "no")
|
||||||
return 0
|
return 0
|
||||||
// otherwise loop again
|
// otherwise loop again
|
||||||
|
|
||||||
|
fun progress(this, length)
|
||||||
|
return length
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,13 @@
|
||||||
/**
|
/*
|
||||||
|
* This file is part of the Fun programming language.
|
||||||
|
* https://fun-lang.xyz/
|
||||||
|
*
|
||||||
|
* Copyright 2025 Johannes Findeisen <you@hanez.org>
|
||||||
|
* Licensed under the terms of the Apache-2.0 license.
|
||||||
|
* https://opensource.org/license/apache-2-0
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
* Implements OP_ECHO: print top-of-stack value without trailing newline.
|
* Implements OP_ECHO: print top-of-stack value without trailing newline.
|
||||||
* Now stores the value into the VM's output buffer and marks it as partial,
|
* Now stores the value into the VM's output buffer and marks it as partial,
|
||||||
* so the CLI can render echo output together with following print output.
|
* so the CLI can render echo output together with following print output.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue