Compare commits

...

3 Commits

Author SHA1 Message Date
Tristan B. Velloza Kildaire 8a3da64009 Blog
- Typo fix
2024-05-02 08:31:19 +02:00
Tristan B. Velloza Kildaire 1672d6953b Blog
- Added table of pull requests
2024-05-02 08:31:06 +02:00
Tristan B. Velloza Kildaire 0d03c53c7e Blog
- Work-in-progress entry fpr the `niknaks` project and its updates
- Added some future TODOs to later fill in
2024-05-02 08:25:04 +02:00
1 changed files with 75 additions and 1 deletions

View File

@ -42,6 +42,19 @@ over the last few months because I have had great fun implementing the various
routines I need for other projects of mine **and** making them available to the
greater D community.
Below are just _some_ of the pull requests (some earlier ones were left out as
I just grabbed the ones which were already open in my browser's tabs).
| Changeset | Link |
|----------------------------------------------------------|-------------------------------------------|
| ⚡ Feature: Generic configuration mechanism | https://github.com/deavmi/niknaks/pull/18 |
| ⚡ Feature: More array operations | https://github.com/deavmi/niknaks/pull/20 |
| ⚡ Feature: Improved prompting framework | https://github.com/deavmi/niknaks/pull/21 |
| ⚡ Feature: Add opIndex support to CacheMap | https://github.com/deavmi/niknaks/pull/19 |
| ⚡ Feature: Prompting framework | https://github.com/deavmi/niknaks/pull/16 |
| ⚡ Feature: Buffer views | https://github.com/deavmi/niknaks/pull/22 |
| ⚡ Feature: Generic tree and visitation framework | https://github.com/deavmi/niknaks/pull/17 |
## CacheMap
One of the additions I made earlier this year was that of a cache map. This is
@ -151,7 +164,7 @@ else
TODO: Add this
## Predicates, Optionals and some tooling
## Predicates and Optionals
One of the things that come sup quite a lot when programming
and dealing with arrays of data (items of the same data type)
@ -190,6 +203,17 @@ There is also a handy `predicateOf(alias)` template used for
constructing predicates from some symbol (either a function
or a delegate).
---
Now onto _optionals_. An optional is basically a safe way to
pass around a value which _may or may **not**_ be there. So
it is "null-safe" (or whatever the functoid people say).
You can construct an `Optional!(T)`, potentially fill it
with a value (depends on your code) and then return it.
The receiving code will check if a value is present _and only
if so_ then it will extract said value out.
### Example code
#### Predicate example
@ -233,6 +257,56 @@ unittest
}
```
#### Optional example
Below we create an `Optional` that is to
potentially hold a `byte` value. In this
case you can construct it from the get go
with a value, but if not then it will be
empty (it is a `struct` type).
```d
/**
* Creating an `Optional!(T)` with a
* value present and then trying to
* get the value, which results in
* said value being returned
*/
unittest
{
Optional!(byte) f = Optional!(byte)(1);
assert(f.isPresent() == true);
try
{
assert(1 == f.get());
}
catch(OptionalException)
{
assert(false);
}
}
```
What you can then do is call `isPresent()` which
will return `true` if a value is present, otherwise
`false`. Any attempt to then call `get()` will throw
an exception **if and only if** the call to `isPresent()`
prior returned `false`, otherwise the byte value
is returned.
## Array tooling
TODO: Add this
## Bits
TODO: Add this
## Debugging
TODO: Add this
## Delay mechanism
One of the things I decided to put together was a programming