admin

rss feed

Book Review: C++ Initialization Story

Written by on November 6, 2023 in Book Review, C++ with 0 Comments
Book Review: C++ Initialization Story

Title: C++ Initialization Story – A Guide Through All Initialization Options and Related C++ Areas Author: Bartłomiej Filipek Publisher: Leanpub Year: 2023 Can you believe that there is a language where “initialization” itself involves many subtleties and a whole book can be devoted to this topic? Yes, modern C++ is such a language! While many […]

Continue Reading

C++20: “constinit” Specifier

Written by on October 15, 2023 in C++, Programming with 0 Comments
C++20: “constinit” Specifier

The constinit specifier, introduced in C++20, is applied to static variables (global and local static) and thread local variables, with the requirement that they either have a zero initialization or they are initialized with a compile-time constant expression. Here is our first example: Line 17 declares a global constinit variable, initialized with a constant value. […]

Continue Reading

C++23: if consteval

Written by on September 24, 2023 in C++, Programming with 0 Comments
C++23: if consteval

“If consteval” is useful in the context of calling a consteval function from within a constexpr function. A consteval function can only be invoked in a constant expression and hence is evaluated at compile-time. On the other hand, a constexpr function may be invoked in a constant expression or non-constant expression. If invoked in a […]

Continue Reading

Simulating Python Zip in Lisp

Written by on September 4, 2023 in LISP, Programming, Python with 1 Comment
Simulating Python Zip in Lisp

The zip() function in Python is a convenient mechanism for iterating over multiple “iterables” in parallel. Looping over lists is a common scenario. Here is the output generated by the above code: Common Lisp does not have such a feature built into the language or as part of the standard library. Of course, we have […]

Continue Reading

std::is_scoped_enum<>

Written by on August 13, 2023 in C++, Programming with 0 Comments
std::is_scoped_enum<>

The type trait “std::is_scoped_enum<T>::value” was introduced in C++23 to check whether the type “T” is a scoped enum type. Another way to use this is std::is_scoped_enum_v<T>. Before getting into this trait in detail, let us briefly recap the differences between unscoped and scoped enums. Unscoped Enums Unscoped enums are the old-style enums. Look at the […]

Continue Reading

The “===” Operator in Julia

Written by on July 23, 2023 in Julia, Programming with 0 Comments
The “===” Operator in Julia

In addition to the conventional “==” operator that checks if two objects are equal, Julia has the “===” operator to check for equality. What is the difference between these two operators? The “==” operator checks whether two objects have the same value. Here are some examples: Cell 5 shows that the RHS float value is […]

Continue Reading

The Sum Type in V Programming Language

Written by on July 2, 2023 in Programming, Vlang with 0 Comments
The Sum Type in V Programming Language

A Sum data type in V language gives us a convenient way to hold objects of many distinct types (at any time, just one object) and hence is a discriminated union. For example, in C++ we have the variant type. Here is an example of sum type in V language: In the above program, the […]

Continue Reading

C++23: “stacktrace” Library

Written by on June 6, 2023 in C++, Programming with 0 Comments
C++23: “stacktrace” Library

The ability to enumerate stack frames at runtime is one of the interesting features introduced in C++23. This is made possible through the <stacktrace> header. The interface is quite simple. Here is a piece of code showing how to use the library. There are 4 functions and here is the call chain: The “dumpStackTrace()” function […]

Continue Reading

std::expected<>

Written by on May 13, 2023 in C++, Programming with 0 Comments
std::expected<>

I had written about std::optional<> in an earlier article. C++23 introduces std::expected<> as an interesting extension to std::optional<>. Whereas std::optional<> contains a value or none at all, std::expected<> contains a value or an error code associated with it. This gives better control to the caller in terms of handling the outcome of the function call. […]

Continue Reading

Defer Statement in V Language

Written by on April 20, 2023 in Programming, Vlang with 0 Comments
Defer Statement in V Language

The defer statement in Vlang causes code to be executed when the enclosing function returns. This feature is inspired by Golang, but is slightly more flexible since it allows any block of code to be associated with defer instead of just a function call. defer is used primarily to handle “clean up” logic, such as […]

Continue Reading

Top