Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 01:30
    bakpakin commented #833
  • 01:28
    bakpakin closed #794
  • 01:28
    bakpakin commented #794
  • Oct 16 22:57
    hdcos commented #794
  • Oct 16 22:53
    llmII commented #794
  • Oct 16 22:50
    hdcos commented #794
  • Oct 16 22:49
    hdcos commented #794
  • Oct 16 21:26
    llmII commented #794
  • Oct 16 21:19
    hdcos commented #794
  • Oct 16 20:28

    bakpakin on v1.18.1

    (compare)

  • Oct 16 20:05

    bakpakin on master

    Prepare for patch release. (compare)

  • Oct 16 17:51

    bakpakin on master

    Fix typo in docstring Merge branch 'master' into jgar… Merge pull request #843 from jg… (compare)

  • Oct 16 17:51
    bakpakin closed #843
  • Oct 16 17:51
    bakpakin synchronize #843
  • Oct 16 17:50

    bakpakin on master

    Support Android (termux) Add android-spawn to meson.buil… Merge pull request #840 from br… (compare)

  • Oct 16 17:50
    bakpakin closed #840
  • Oct 16 15:49
    jgarte opened #843
  • Oct 16 06:43
    sogaiu commented #840
  • Oct 16 02:51
    bradms commented #840
  • Oct 16 02:42
    bradms commented #840
Zach Smith (subsetpark)
@subsetpark:matrix.org
[m]
As of right now, it's only possible to create new abstract types from the C layer; but there's a kind of "middle layer" of Janet built-ins that are neither native data types (eg :number, :string) but are still implemented in C and can't be trivially reproduced at the Janet layer. Eg:
repl:9:> (def conn (net/listen "localhost" 100084))
<core/stream 0x56166ACCEBF0>
repl:10:> (abstract? conn)
true
But, because right now, abstract types are extremely opaque and basically an implementation detail, I don't think they're really documented.
(net/listen is actually a really good refutation of my previous example, as well, because if you call pairs or keys on a core/stream, it will block indefinitely)
saikyun
@saikyun
Hm, okay, so maybe it's not worth trying to create them myself?
Eric Shimizu Karbstein
@GrayJack
If you want to expose some external type to Janet, Abstract type is the way to go
saikyun
@saikyun
Okay, but how? :)
Are there any code examples of people having done this?
yumaikas-
@yumaikas:matrix.org
[m]
I mean, there's the Janet standard library, no?
Eric Shimizu Karbstein
@GrayJack
I think the simplest example is the Janet core library for the 64bit integers
bakpakin
@bakpakin:matrix.org
[m]
Yes, many languages that bind to C have an analogue to abstract types. For example, in Lua they are called userdata.
Jaylib also has many such types
sogaiu
@sogaiu:matrix.org
[m]
@Saikyun: this might be another example: https://github.com/sogaiu/janet-pcg-random
andrewchambers
@andrewchambers
@Saikyun I have done a lot of libraries that use abstract types
jaylib will use them too
oh, as bakpakin said
saikyun
@saikyun
Thanks for all examples :) will save them
andrewchambers
@andrewchambers
all an abstract type really is
is a slot of memory managed by the janet garbage collector, and a type
the type is associated with a set of callbacks
so your C code can do whatever it wants with that memory
saikyun
@saikyun
That sounds reasonable :) I just didn't have an easy way to relate to it. With the examples I understand a bit better
Thanks for explaining
Zach Smith (subsetpark)
@subsetpark:matrix.org
[m]
Has anybody got an example of how to use maclintf?
I'm particularly not really sure what the levels should be
oh, maybe it's :relaxed etc...
sogaiu
@sogaiu:matrix.org
[m]

that interpretation seems consistent with the content of this: https://github.com/janet-lang/janet/issues/644#issuecomment-851054482

Each lint message has the following structure:

(level line column message)

Where level is a keyword lint level, line and column are the line and column of the source code where the lint issue occurred, and message is a user facing message.

and this line: https://github.com/janet-lang/janet/blob/master/src/boot/boot.janet#L1798 inside the definition of maclintf has:

(array/push lints [level l c msg])
bakpakin
@bakpakin:matrix.org
[m]
If you are wondering how the levels are defined, it is entirely by the lint-levels binding in boot.janet
(def- lint-levels
  {:none 0
   :relaxed 1
   :normal 2
   :strict 3
   :all math/inf})
This is technically not supported but if you were to add more mappings to this table, you could have more lint levels. Each level is a keyword that maps to a priority.
The way to think about it is, more important lint messages will have a lower priority number.
The user set lint thresholds are maximums
bakpakin
@bakpakin:matrix.org
[m]
for example, if -w normal is passed an argument to janet, any lint message of level 2 or below will print a warning message
if -x relaxed is passed, any lint message of level 1 or below will cause a compiler error
Yes, I need to update the Janet documentation on this, although I hope to do that this weekend.
bakpakin
@bakpakin:matrix.org
[m]
:point_up: Edit: This is technically not supported but if you were to add more mappings to this struct, you could have more lint levels. Each level is a keyword that maps to a priority.
Zach Smith (subsetpark)
@subsetpark:matrix.org
[m]

Currently compiling a native lib and getting this:

rl.c:1:10: fatal error: janet.h: No such file or directory

What's the likelihood the janet package for this os (void linux) is misconfigured?

bakpakin
@bakpakin:matrix.org
[m]
try jpm --verbose build
Zach Smith (subsetpark)
@subsetpark:matrix.org
[m]
ah! It's one of those with a separate -devel package
bakpakin
@bakpakin:matrix.org
[m]
ok good to hear
Zach Smith (subsetpark)
@subsetpark:matrix.org
[m]
("it" being Void in general)
Zach Smith (subsetpark)
@subsetpark:matrix.org
[m]
Zach Smith (subsetpark)
@subsetpark:matrix.org
[m]
  • and then would none be for what I ws describing before as info?
(ie, a message emitted by the compiler by one that should not halt compilation at any strictness level)
bakpakin
@bakpakin:matrix.org
[m]
More or less, but a :relaxed message is actually the noisiest. :relaxed here means it will show up if the threshold is set to :relaxed.
Zach Smith (subsetpark)
@subsetpark:matrix.org
[m]
Hm - is there a difference between showing up and failing the compile/returning a non-zero error code?
bakpakin
@bakpakin:matrix.org
[m]
The default warn threshold is normal
and the default error threshold is none
Zach Smith (subsetpark)
@subsetpark:matrix.org
[m]
In other words, is it possible using this system to always show this message, but change whether it's a failure or just informational?
bakpakin
@bakpakin:matrix.org
[m]
You shouldn't always show a lint message
but more or less, yes