![]() |
VOOZH | about |
dotnet add package magic.lambda.slots --version 17.2.1
NuGet\Install-Package magic.lambda.slots -Version 17.2.1
<PackageReference Include="magic.lambda.slots" Version="17.2.1" />
<PackageVersion Include="magic.lambda.slots" Version="17.2.1" />Directory.Packages.props
<PackageReference Include="magic.lambda.slots" />Project file
paket add magic.lambda.slots --version 17.2.1
#r "nuget: magic.lambda.slots, 17.2.1"
#:package magic.lambda.slots@17.2.1
#addin nuget:?package=magic.lambda.slots&version=17.2.1Install as a Cake Addin
#tool nuget:?package=magic.lambda.slots&version=17.2.1Install as a Cake Tool
The magic.lambda.slots project provides the ability to create, invoke (signal), modify, inspect, and delete dynamic slots in Hyperlambda. More specifically, this project provides the following slots.
/*
* First we create a dynamic slot.
*/
slots.create:foo
return-value:int:57
/*
* Then we invoke it.
*/
signal:foo
After evaluation of the above Hyperlambda, the value of the [signal] node will be 57. Notice, if you invoke [slots.create] for a slot that has already been created, the old slot will be overwritten with the new lambda object you pass into it. Also notice that if you try to invoke a slot that doesn't exist, or you try to get its content, an exception will be thrown.
Also realize that when you create a slot, it is not persisted in any ways - Implying if the web server process is restarted, your slot will disappear. To avoid this, put the creation of your slot inside a file in a folder called "magic.startup" in your module's folder, e.g. "/files/modules/foo-module/magic.startup/create-slot.hl". All files inside of modules that exists within a "magic.startup" folder will be executed every time your web server restarts for some reasons.
Creates a dynamic slot that can be invoked using [signal]. Below is an example.
slots.create:foo
return-value:int:57
Notice, the above slot aren't persisted in any ways, implying if your web server restarts its process, your slot is removed. If you want to make sure your slots becomes a permanent part of your application, you need to make sure you are somehow creating it during server startup, which can normally be done on a per module basis, by putting a Hyperlambda file into your module's "magic.startup" folder, which makes sure the code is executed during startup of your web app.
Invokes a previously created dynamic slot. Assuming you have created the foo slot from the create slot example, you can invoke the slot using the following Hyperlambda.
signal:foo
After evaluating the above Hyperlambda, the [signal] node will end up having a value of "57".
Notice - This slot obeys by the rules of [whitelist] invocations from magic.lambda, allowing you to declare a list of dynamic slots, which are exclusively allowed to be invoked temporarily inside of an invocation to whitelist, allowing you to restrict some piece of potentially unsafe code to only signal a pre-defined list of dynamically created slots. Below is an example.
slots.create:foo1
return-value:Safe
slots.create:foo2
return-value:Unsafe
whitelist
vocabulary
signal
signal:foo1
.lambda
// Assuming you have a [foo1] slot created, this will work
signal:foo1
// This will throw, since [foo2] is not whitelisted
signal:foo2
Basically, only the slots declared in the above [vocabulary] will be allowed to be invoked inside of the above [.lambda] object. You must have your dynamic slots declared as signal:slot-name, such as the above illustrates. And in order to signal dynamic slots at all, you'll need to (obviously) whitelist [signal] itself, as illustrated in the above code. Read more about [whitelist] in the magic.lambda project. Inside your slots though any [whitelist] invocations will simply be ignored, allowing you to whitelist a single dynamic slot, for then to ignore what the slot itself is doing internally. This might create security issues for you if you have dynamically created slots that for some reasons execute lambda object supplied to them. Hence as a general rule of thumb, you should avoid whitelisting slots that executes lambda objects supplied to them.
The [execute] slot is an alias for [signal], but it will [unwrap] all children nodes, automatically transform any expressions to their static value equivalents, allowing you to combine [unwrap] and [signal] into one invocation. This makes usage slightly less verbose for cases such as the following.
.args
foo1:bar1
foo2:bar2
execute:whatever-slot
arg1:x:@.args/*/foo1
arg2:x:@.args/*/foo2
In the above example both arguments to our "whatever-slot" invocation will be evaluated before the slot is invoked, resulting in [arg1] and [args2] having the values of "bar1" and "bar2" respectively.
If you pass in a node named [node_reference] using the above syntax, this node will be especially handled, and passed in by reference instead of evaluated as a single expression value. Consider the following alternative to the above.
.args
foo1:bar1
foo2:bar2
execute:whatever-slot
node_reference:x:@.args
Inside your above "whatever-slot" you will now have access to the entire [.args] node by reference. It might help to execute the following to understand.
.args
foo1:howdy
foo2:world
slots.create:foo
lambda2hyper:x:../*
return:x:-
execute:foo
node_reference:x:@.args/*
Invokes a previously created dynamic slot. This slots works exactly the same as [signal] except it does not throw an exception if the slot does not exist. Assuming you have created the foo slot from the create slot example, you can invoke the slot using the following Hyperlambda.
try-signal:foo
Returns the entire lambda code for a previously created dynamic slot. Example can be found below.
slots.create:foo
return-value:int:57
slots.get:foo
Deletes a previously created dynamic slot. The following example will throw an exception.
slots.create:foo
return-value:int:57
slots.delete:foo
// Throws exception, since [foo] no longer exists.
slots.get:foo
Returns a bunch of nodes (lambda) from your slot. Can only be invoked from the inside of a dynamically created slot, and other slots explicitly creating a return context. An example can be found below.
slots.create:foo
return-nodes
integer-value:int:57
string-value:Foo bar
signal:foo
Returns a single value from your slot. Can only be invoked from the inside of a dynamically created slot, and other slots explicitly creating a return context. An example can be found below.
slots.create:foo
return-value:This becomes the returned value from your slot
signal:foo
Returns true if the specified slot exists. Example can be found below.
slots.create:foo
return-value:Blah, blah, blah ...
slots.exists:foo
slots.exists:DOES-NOT-EXISTS
Returns the names of all dynamically created slots to caller. Example can be found below.
slots.vocabulary
Magic is 100% Open Source and you can find the primary project GitHub page here.
The source code for this repository can be found at github.com/polterguy/magic.lambda.slots, and you can provide feedback, provide bug reports, etc at the same place.
The projects is copyright Thomas Hansen 2023 - 2024, and professionally maintained by AINIRO.IO.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 1 NuGet packages that depend on magic.lambda.slots:
| Package | Downloads |
|---|---|
|
magic.library
Helper project for Magic to wire up everything easily by simply adding one package, and invoking two simple methods. When using Magic, this is (probably) the only package you should actually add, since this package pulls in everything else you'll need automatically, and wires up everything sanely by default. To use package go to https://polterguy.github.io |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 17.2.1 | 1,877 | 1/22/2024 |
| 17.2.0 | 386 | 1/22/2024 |
| 17.1.7 | 463 | 1/12/2024 |
| 17.1.6 | 419 | 1/11/2024 |
| 17.1.5 | 428 | 1/5/2024 |
| 17.0.1 | 486 | 1/1/2024 |
| 17.0.0 | 642 | 12/14/2023 |
| 16.11.5 | 526 | 11/12/2023 |
| 16.9.0 | 531 | 10/9/2023 |
| 16.7.0 | 856 | 7/11/2023 |
| 16.4.1 | 630 | 7/2/2023 |
| 16.4.0 | 607 | 6/22/2023 |
| 16.3.1 | 564 | 6/7/2023 |
| 16.3.0 | 534 | 5/28/2023 |
| 16.1.9 | 910 | 4/30/2023 |
| 15.10.11 | 699 | 4/13/2023 |
| 15.9.1 | 818 | 3/27/2023 |
| 15.9.0 | 681 | 3/24/2023 |
| 15.8.2 | 750 | 3/20/2023 |
| 15.7.0 | 633 | 3/6/2023 |