Skip to content

Commit 8e40254

Browse files
author
Florian Thake
committed
VERSION: 0.16.0 - Error type, catch statement, default shared params, BSON.
- Please, see changelog.txt for commit details and changes and also have a look into Deprecation_and_Breaking_Changes.txt.
1 parent 3e85a00 commit 8e40254

33 files changed

Lines changed: 1177 additions & 296 deletions

COPYRIGHT.TXT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Except where otherwise noted all files included are copyrighted by Florian Thake.
22

3-
Copyright (C) 2024 Florian Thake <contact |at| tea-age.solutions>.
3+
Copyright (C) 2025 Florian Thake <contact |at| tea-age.solutions>.
44

55

66
The TeaScript C++ Library

Deprecation_and_Breaking_Changes.txt

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ TeaScript Breaking Changes in the actual release
33

44
Changes in TeaScript language
55
------------------------------------
6+
Introduced distinct Error type for a clean error handling.
7+
Added catch statement for easy error handling similar as in Zig.
8+
examples (assuming _strtonum returns an Error on error):
9+
def number := _strtonum( "abc" ) catch 2 // on error number is 2
10+
def number := _strtonum( "abc" ) catch( err ) return err // on error early return with err
11+
see examples_v0.16.tea ore corelibrary_test06.tea for more examples.
12+
13+
614
Function parameters without assign specifier are shared assign by default now.
715
Furthermore, explicit shared function parameters without 'const' or 'def' specifier are set
816
implicit to 'auto' now. They will be either 'const' or 'def' depending on the rhs argument/passed parameter.
@@ -37,7 +45,17 @@ TeaScript Breaking Changes in the actual release
3745
strtrim() first parameter was a const @= by accident. changed to correct def @=.
3846
Now the function will not take a const string as input parameter anymore!
3947
This worked because of a const correct bug, which has been fixed now (see C++ API level breaking changes below).
40-
48+
49+
Following functions are now returning Error instead of Bool(false):
50+
_strtonum/_strtonumex
51+
to_i64/to_f64
52+
_strfromascii
53+
read[text]file
54+
read[toml|json]file
55+
read[toml|json]string
56+
write[toml|json]string
57+
read/writebsonbuffer
58+
all _buf_get_x functions
4159

4260
Changes on C++ API level
4361
------------------------------------
@@ -57,6 +75,8 @@ TeaScript Breaking Changes in the actual release
5775
tuple::foreach_element/foreach_named_element are working now with either a const ValueObject or a mutable one.
5876
If the functor takes mutable objects all nested const objects (if any) will be skipped.
5977
This is a breaking change but the old behavior was faulty as it allowed to access const elements as mutable reference.
78+
79+
fixed typo in Collection::RemoveValueByKeyWithPlaceholder()
6080

6181

6282
Visibility of Core Library functions
@@ -87,4 +107,7 @@ TeaScript list of deprecated parts
87107

88108
class LibraryFunction0<> to LibraryFunction5<> are deprecated now.
89109
Please, use the new and generic one fits for all LibraryFunction<> instead.
110+
111+
_f64toi64 is now deprecated.
112+
Please, use the cast operator 'as' instead (recommended) (or alternatively to_i64).
90113

TeaScript_SyntaxHighlighting_DarkMode_Notepad++.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
<Keywords name="Folders in comment, open"></Keywords>
2525
<Keywords name="Folders in comment, middle"></Keywords>
2626
<Keywords name="Folders in comment, close"></Keywords>
27-
<Keywords name="Keywords1">if else repeat forall in is as typename typeof func def const undef is_defined debug with stop loop return mod not or and false true suspend yield _Exit</Keywords>
28-
<Keywords name="Keywords2">TypeInfo i64 f64 u8 u64 Bool String Function Tuple IntegerSequence NaV Number Const Buffer</Keywords>
27+
<Keywords name="Keywords1">if else repeat forall in is as typename typeof func def const undef is_defined debug with stop loop return mod not or and false true suspend yield _Exit catch</Keywords>
28+
<Keywords name="Keywords2">TypeInfo i64 f64 u8 u64 Bool String Function Tuple IntegerSequence NaV Number Const Buffer Error</Keywords>
2929
<Keywords name="Keywords3"></Keywords>
3030
<Keywords name="Keywords4"></Keywords>
3131
<Keywords name="Keywords5"></Keywords>

TeaScript_SyntaxHighlighting_Notepad++.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
<Keywords name="Folders in comment, open"></Keywords>
2525
<Keywords name="Folders in comment, middle"></Keywords>
2626
<Keywords name="Folders in comment, close"></Keywords>
27-
<Keywords name="Keywords1">if else repeat forall in is as typename typeof func def const undef is_defined debug with stop loop return mod not or and false true suspend yield _Exit</Keywords>
28-
<Keywords name="Keywords2">TypeInfo i64 f64 u8 u64 Bool String Function Tuple IntegerSequence NaV Number Const Buffer</Keywords>
27+
<Keywords name="Keywords1">if else repeat forall in is as typename typeof func def const undef is_defined debug with stop loop return mod not or and false true suspend yield _Exit catch</Keywords>
28+
<Keywords name="Keywords2">TypeInfo i64 f64 u8 u64 Bool String Function Tuple IntegerSequence NaV Number Const Buffer Error</Keywords>
2929
<Keywords name="Keywords3"></Keywords>
3030
<Keywords name="Keywords4"></Keywords>
3131
<Keywords name="Keywords5"></Keywords>

changelog.txt

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,57 @@ NOTE: The dates are not the release dates, but a last commit date.
66

77

88
================
9-
VERSION 0.16.0 (not released yet, pre-release)
10-
================
9+
VERSION 0.16.0, Sa Dec 20 12:24:43 2025
10+
================
11+
VERSION: 0.16.0 - Error type, catch statement, default shared params, BSON.
12+
13+
EXAMPLES: added example_v0.16.tea for demo catch, Error and bson.
14+
- added bson test to corelibrary_test05.tea
15+
COLLECTION: fixed typo in RemoveValueByKeyWithPlaceholder().
16+
ARITHMETIC: (optimized) don't check for overflow if types are same in Convert function.
17+
18+
CORELIB: raised API level to 1 (because changed to Error return).
19+
CORELIB: made _f64toi64 DEPRECATED!
20+
- removed all internal usage of _f64toi64.
21+
22+
CORELIB (BREAKING!): changed all _buf_get_x functions to return Error instead of Bool(false).
23+
CORELIB (BREAKING!): clean and proper Error handling for more functions which
24+
... returned Bool(false) on error but has a different type as Bool on success.
25+
... They will now return the new Error type on error.
26+
- changed functions: _strfromascii, read[text]file, read[toml|json]file,
27+
read[toml|json]string, write[toml|json]string, read/writebsonbuffer
28+
29+
CORELIB (BREAKING!): _strtonum/_strtonumex now return an Error instead of a Bool(false)
30+
CORELIB (BREAKING!): changed to_i64/to_f64 return an Error instead of Bool(false).
31+
- improved to_number() for Number input (and Error input)
32+
33+
TSVM: added TSVM instruction Catch for execute Error path if Error/NaV is on top stack.
34+
TSVM: added TSVM instruction Swap for swapping top and top-1
35+
FIXED: (in TSVM) stack cleanup for some early return cases, e.g. def x := 10 + return 123
36+
... needed for def n := foo() catch return -1 / def m := baz() catch( err ) { return err }
37+
FIXED: (in TSVM) broken stack after debug operator.
38+
39+
CORELIB: added _error_[get_code/get_name/get_message], make_runtime_error
40+
TEST: added corelibrary_test06.tea and v0.16 test in test01
41+
TEASCRIPT: as operator: added cast from NaV to Error, don't cast if type is same already
42+
- as operator: Error cannot be casted and stays as Error.
43+
MISC: Added syntaxhighlighting for catch and Error.
44+
45+
TEASCRIPT: added catch statement for easy error handling similar as in Zig.
46+
- examples (assuming _strtonum returns an Error on error):
47+
def number := _strtonum( "abc" ) catch 2 // on error number is 2
48+
def number := _strtonum( "abc" ) catch( err ) return err // on error early return with err
49+
50+
TEASCRIPT: Introduced distinct Error type for a clean error handling.
51+
- Errors consist of an error code and a message.
52+
- Errors can be created via make_runtime_error(s) or simply cast a String into Error.
53+
- Errors can be concatenated to strings and in boolean contexts they evaluate to false.
54+
- For the time being all Error related classes and functions are considered EXPERIMENTAL.
55+
PROJ: split class TypeInfo and TypePtr into new TypeIinfo.hpp.
56+
57+
HOST: added :inspect function command printing AST or TSVM instruction of a function.
58+
59+
BUILD: Support VS 17.14 by targeting latest installed WinSDK
1160
BUILD: Support Visual Studio 2022 17.13 with C++23 preview.
1261
FIX: C++23 - Printing without libfmt. Use std::print again instead of std::vprint_unicode.
1362
... On Linux it just works,
@@ -19,6 +68,10 @@ VERSION 0.16.0 (not released yet, pre-release)
1968
- added readbsonbuffer and writebsonbuffer to core library for ...
2069
... Tuple <--> BSON Buffer conversion.
2170

71+
HOST: added ascii/uttf-8 art logo to welcome screen of interactive shell.
72+
- can be suppressed with --no-logo
73+
- fixed default eval mode for some implicit interactive shell launches, e.g., -i or --silent.
74+
2275
CLEAN: finally removed deprecated CoreLibrary::ExitScript().
2376
- Please, use _Exit val instead or directly throw teascript::control::Exit_Script from C++.
2477

@@ -63,6 +116,7 @@ VERSION 0.16.0 (not released yet, pre-release)
63116
ASTNODE: as operator - optimized the ifs to a switch.
64117
HOST: changed copyright year to 2025
65118

119+
66120
================
67121
VERSION 0.15.1, Sun Nov 03 13:25:32 2024
68122
================

demo/compile_clang.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
# -stdlib=libc++
22
# -stdlib=libstdc++
33
#
4-
# for color + format support: -I../../fmt/fmt-11.0.2/include/
5-
# for TOML support: -I../../tomlplusplus/tomlplusplus-3.4.0/include/
4+
# for color + format support: -I../../fmt/fmt-11.1.4/include/
5+
# for TOML support: -I../../tomlplusplus/tomlplusplus-3.4.0/include/
6+
# extensions include -I../extensions/include/
7+
# modules include -I../modules/include/
8+
# nlohmann: -I../../nlohmann/nlohmann_3.11.3/include/
9+
# Boost: -I../../boost_1_86_0/
10+
# Rapid: -I../../rapidjson/include/
11+
#
12+
# example with webpreview enabled:
13+
# clang++-14 -std=c++20 -stdlib=libc++ -Wall -O2 -DNDEBUG -DTEASCRIPT_ENGINE_USE_WEB_PREVIEW=1 -I../modules/include/ -I../../fmt/fmt-11.1.4/include/ -I../include/ ../modules/source/Webpreview.cpp <other .cpp>
614

715
clang++-14 -std=c++20 -stdlib=libc++ -Wall -O2 -DNDEBUG \
8-
-I../../fmt/fmt-11.0.2/include/ \
16+
-I../../fmt/fmt-11.1.4/include/ \
917
-I../include/ \
1018
suspend_thread_demo.cpp \
1119
coroutine_demo.cpp \

demo/compile_gcc.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1-
# for color + format support: -I../../fmt/fmt-11.0.2/include/
2-
# for TOML support: -I../../tomlplusplus/tomlplusplus-3.4.0/include/
1+
# for color + format support: -I../../fmt/fmt-11.1.4/include/
2+
# for TOML support: -I../../tomlplusplus/tomlplusplus-3.4.0/include/
3+
# extensions include -I../extensions/include/
4+
# modules include -I../modules/include/
5+
# nlohmann: -I../../nlohmann/nlohmann_3.11.3/include/
6+
# Boost: -I../../boost_1_86_0/
7+
# Rapid: -I../../rapidjson/include/
8+
#
9+
# example with webpreview enabled:
10+
# g++ -std=c++20 -Wall -O2 -DNDEBUG -DTEASCRIPT_ENGINE_USE_WEB_PREVIEW=1 -I../modules/include/ -I../../fmt/fmt-11.1.4/include/ -I../include/ ../modules/source/Webpreview.cpp <other .cpp>
311

4-
g++ -std=c++20 -Wall -O2 -DNDEBUG -I../../fmt/fmt-11.0.2/include/ -I../include/ \
12+
g++ -std=c++20 -Wall -O2 -DNDEBUG -I../../fmt/fmt-11.1.4/include/ -I../include/ \
513
suspend_thread_demo.cpp \
614
coroutine_demo.cpp \
715
teascript_demo.cpp \

demo/corelibrary_test05.tea

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,7 @@ print_success( "ok.\n" )
473473

474474
print( "testing bigger json structure ... " )
475475

476-
{
477-
const json_str := """"
476+
const json_str := """"
478477
{
479478
"type": "FeatureCollection",
480479
"features": [
@@ -513,6 +512,7 @@ print( "testing bigger json structure ... " )
513512
}
514513
""""
515514

515+
{
516516
def json := readjsonstring( json_str )
517517
TEST_EQ( typeof json, Tuple, "wrong json value type!" )
518518
_out( "\n" )
@@ -605,4 +605,31 @@ contributors = [
605605
print_warning( "\nTOML is not present! TOML test skipped!\n" )
606606
}
607607

608+
print( "testing BSON extensions ... " )
609+
610+
// You must use nlohmann as JSON adapter for have BSON support!
611+
def bson_present := is_defined readbsonbuffer and is_defined writebsonbuffer
612+
if( bson_present ) {
613+
// first create some json tuple.
614+
def json := readjsonstring( json_str )
615+
// json tuple to bson
616+
def bson_buffer := writebsonbuffer( json )
617+
TEST_EQ( typeof bson_buffer, Buffer, "unexpected BSON type!" )
618+
619+
//println( "\nContent:\n%(bson_buffer)" )
620+
621+
def json_new := readbsonbuffer( bson_buffer )
622+
TEST_EQ( typeof json_new, typeof json, "roundtrip failed! wrong type!" )
623+
TEST_EQ( json_new, json, "roundtrip failed! not equal structure!" )
624+
625+
print_success( "ok.\n" )
626+
} else {
627+
print_warning( "\nBSON support is not present. BSON test skipped!\n")
628+
print_warning( "You need ")
629+
maybe_cprint( make_rgb( 210, 170, 90 ), "nlohmann::json" )
630+
print_warning( " as JSON adapter, you have " )
631+
maybe_cprint( make_rgb( 210, 170, 90 ), features.json_adapter % "\n" )
632+
}
633+
634+
608635
print_success( "=== TEST PASSED ===\n" )

0 commit comments

Comments
 (0)