magic.lambda.slots 13.3.4

.NET Standard 2.0
Install-Package magic.lambda.slots -Version 13.3.4
dotnet add package magic.lambda.slots --version 13.3.4
<PackageReference Include="magic.lambda.slots" Version="13.3.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add magic.lambda.slots --version 13.3.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: magic.lambda.slots, 13.3.4"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install magic.lambda.slots as a Cake Addin
#addin nuget:?package=magic.lambda.slots&version=13.3.4

// Install magic.lambda.slots as a Cake Tool
#tool nuget:?package=magic.lambda.slots&version=13.3.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Creating dynamic slots from Hyperlambda

This project provides the ability to create, invoke (signal), modify, inspect, and delete dynamic slots for Magic. More specifically, this project provides the following slots.

  • [signal] - Invokes a dynamically create slot that has been created with the [slots.create] slot
  • [slots.create] - Creates a dynamic slot, that can be invoked with the [signal] slot
  • [slots.get] - Returns the entire lambda object for a slot that has been previously created with the [slots.create] slot
  • [slots.delete] - Deletes a slot that has been previously created with the [slots.create] slot
  • [slots.exists] - Returns true of the given slot exists
  • [return-nodes] - Returns a bunch of nodes to caller from inside of your slot
  • [return-value] - Returns a single value to caller from inside of your slot
  • [return] - Returns either a list of nodes, or a single value, or both, depending upon the results of its expression, or whether or not it has a static value, or a list of nodes
  • [slots.vocabulary] - Returns the names of all dynamically created 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.

[slots.create]

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.

[signal]

Invokes a previously created dynamic slot. Assuming you have executed the above code snippet, 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.

[slots.get]

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

[slots.delete]

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

[return-nodes]

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

[return-value]

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

[slots.exists]

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

[slots.vocabulary]

Returns the names of all dynamically created slots to caller. Example can be found below.

slots.vocabulary

Project website

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.

Quality gates

  • Build status
  • Quality Gate Status
  • Bugs
  • Code Smells
  • Coverage
  • Duplicated Lines (%)
  • Lines of Code
  • Maintainability Rating
  • Reliability Rating
  • Security Rating
  • Technical Debt
  • Vulnerabilities
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

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

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
13.3.4 270 5/9/2022
13.3.0 174 5/1/2022
13.2.0 209 4/21/2022
13.1.0 233 4/7/2022
13.0.0 101 4/5/2022
11.0.7 274 3/10/2022
11.0.5 196 3/2/2022
11.0.4 150 2/22/2022
11.0.3 169 2/9/2022
11.0.2 163 2/6/2022
11.0.1 133 2/5/2022
10.0.21 142 1/28/2022
10.0.20 147 1/27/2022
10.0.19 135 1/23/2022
10.0.18 122 1/17/2022
10.0.15 332 12/31/2021
10.0.14 197 12/28/2021
10.0.8 499 12/22/2021
10.0.7 217 12/22/2021
10.0.5 302 12/18/2021
9.9.9 991 11/29/2021
9.9.3 342 11/9/2021
9.9.2 252 11/4/2021
9.9.0 395 10/30/2021
9.8.9 301 10/29/2021
9.8.7 271 10/27/2021
9.8.6 272 10/27/2021
9.8.5 268 10/26/2021
9.8.0 628 10/20/2021
9.7.9 275 10/19/2021
9.7.5 756 10/14/2021
9.7.0 393 10/9/2021
9.6.6 608 8/14/2021
9.2.0 3,509 5/26/2021
9.1.4 612 4/21/2021
9.1.0 444 4/14/2021
9.0.0 404 4/5/2021
8.9.9 518 3/30/2021
8.9.3 758 3/19/2021
8.9.2 474 1/29/2021
8.9.1 483 1/24/2021
8.9.0 568 1/22/2021
8.6.9 1,816 11/8/2020
8.6.6 1,063 11/2/2020
8.6.0 2,086 10/28/2020
8.5.0 963 10/23/2020
8.4.2 1,789 10/16/2020
8.4.1 590 10/16/2020
8.4.0 1,060 10/13/2020
8.3.1 1,417 10/5/2020
8.3.0 671 10/3/2020
8.2.2 1,099 9/26/2020
8.2.1 676 9/25/2020
8.2.0 723 9/25/2020
8.1.17 3,740 9/13/2020
8.1.16 323 9/13/2020
8.1.15 625 9/12/2020
8.1.11 1,634 9/11/2020
8.1.10 375 9/6/2020
8.1.9 1,001 9/3/2020
8.1.8 692 9/2/2020
8.1.7 574 8/28/2020
8.1.4 573 8/25/2020
8.1.3 633 8/18/2020
8.1.2 575 8/16/2020
8.1.1 683 8/15/2020
8.1.0 294 8/15/2020
8.0.1 1,450 8/7/2020
8.0.0 600 8/7/2020
7.0.1 699 6/28/2020
7.0.0 679 6/28/2020
5.0.1 1,107 5/30/2020
5.0.0 3,333 2/25/2020
4.0.4 4,310 1/27/2020
4.0.3 662 1/27/2020
4.0.2 756 1/16/2020
4.0.1 755 1/11/2020
4.0.0 725 1/5/2020
3.1.1 2,335 12/4/2019
3.1.0 1,574 11/10/2019
3.0.0 2,174 10/23/2019
2.0.3 2,487 10/18/2019
2.0.2 1,029 10/18/2019
2.0.1 2,008 10/15/2019
2.0.0 854 10/13/2019
1.1.9 674 10/11/2019
1.1.8 670 10/10/2019
1.1.7 311 10/9/2019
1.1.6 314 10/7/2019
1.1.5 314 10/6/2019
1.1.4 301 10/6/2019
1.1.2 305 10/5/2019