@oprypin:matrix.org I have a few shards (example) that run on limited platforms. Some are POSIX only. One is OpenBSD only. Future ones may be window only. What say you of 2 additional options for shard.yaml?
A platform flag. If it matches the shard is included. If not the shard is automatically pruned.
# For mmap platforms: - !windows - posix (or) # For mostly posix shards platforms: - !macos - posix
A 2nd platform flag with identical semantics should be available for dependencies
dependencies: generic-file-polling.cr: platforms: - !linux inotify.cr: platforms: - linux
Why both? These options aren't mutually exclusive.
Sometimes the shard author knows it won't work on specific platforms and they can specify them.
Other times the author may choose a more specific solution and wish to exclude a generic shard (see inotify example above). Or they could be working on an newer/older system where a
shard specified dependency doesn't work in their particular situation.
platform: posix. Create a windows anonymous memory shard (No mmap equivalent that handles all functions) with
platform: windows. Create a generic anon memory wrapper shard that includes both. Create a guard page key holding shard similar to
sodium_mallocusing the anon memory shard.
mmaplike mapping a file, I can't do that on windows as it uses a completely different API
platformas a restriction wouldn't be used with pure portable crystal shards, only platform specific shards.
platformas a dependency may be specified to override. See the inotify example. Generic file polling may work everywhere but on linux you may prefer
inotify. On BSD eventually
kqueue. Although technically those should have their own platform limitations so the dependency limit should only be placed on generic file polling.
alias PermissiveType = Array(String | Int32) | String s : PermissiveType = "hello world" #works ss : PermissiveType = ["hello", "world"] # must be (Array(Int32 | String) | String), not Array(String)
PermissiveTypeis strictly more permissive than
Array(String)this cast should be possible - any possible value of that more restrictive type should satisfy the more permissive type.
@ryanprior:matrix.org What you are running into is that while one can logically look at an Array(String) and see that an Array(String | Int32) can store everything in it, type specifications are very specific, and your type specification is for two things, either an Array(String | Int32), or String, and what you are trying to assign is an Array(String), which is not either of those things.
ss : PermissiveType = Array(String | Int32).new + ["hello", "world"]
That will create an array with a type signature that matches what PermissiveType allows.
@didactic-drunk that complete functionality doesn't exist so far as I am aware, but all of the building blocks exist. Maybe it can be my macro-hacking project of the week to build it.
Right now I am picturing something such as simple as
include CallTrace, followed by an annotation on top of any method that one want's to build a call tracing stack for.
The actual call trace would be accessible at any time.