Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Dec 01 01:50

    bakpakin on master

    Update to dev versions. Merge branch 'master' of github… (compare)

  • Nov 30 20:17

    bakpakin on master

    Update location of current file… Merge pull request #883 from py… (compare)

  • Nov 30 20:17
    bakpakin closed #883
  • Nov 29 01:13
    pyrmont edited #883
  • Nov 29 01:12
    pyrmont opened #883
  • Nov 27 16:01

    bakpakin on v1.19.0

    (compare)

  • Nov 27 16:01

    bakpakin on master

    Prepare for 1.19.0 release. (compare)

  • Nov 27 15:28
    bakpakin closed #881
  • Nov 27 15:28

    bakpakin on master

    Don't call wait twice when clos… (compare)

  • Nov 27 00:53
    bakpakin commented #881
  • Nov 27 00:53
    bakpakin commented #881
  • Nov 27 00:44

    bakpakin on master

    Fix leaking file descriptors to… Merge branch 'master' of github… (compare)

  • Nov 26 23:37
    bakpakin labeled #881
  • Nov 26 23:11
    andrewchambers commented #881
  • Nov 26 22:45
    andrewchambers commented #881
  • Nov 26 22:41
    llmII commented #881
  • Nov 26 19:57
    llmII commented #881
  • Nov 26 19:55
    llmII commented #881
  • Nov 26 18:34

    bakpakin on master

    Fix math/gamma and add math/log… Merge pull request #880 from pe… (compare)

  • Nov 26 18:34
    bakpakin closed #880
andrewchambers
@andrewchambers
so you can swap it out i guess
saikyun
@saikyun
The second one sounds interesting. How would I do that? :D
to be concrete, I have a callback function that I give to miniaudio (used by raylib) in order to generate sound. What I would like to do is to switch out the contents of that function, and I figured the easiest way would be to have it call a function pointer, and I'd change out that function pointer somehow
andrewchambers
@andrewchambers
i dunno, this package is just a prototype
if you've done some C stuff before extracting and casting C function pointers is not that hard
but im sure the libtcc api would let you do some other stuff too
saikyun
@saikyun
I have done it, but I've forgotten most, haha
Okay, thanks
andrewchambers
@andrewchambers
i've seen some other stuff around regarding hot reloading C code
maybe google that a bit haha
saikyun
@saikyun
I'll do that :) thanks for the feedback
saikyun
@saikyun
Is there a way to expose c struct fields for modifications? Eg change a float
andrewchambers
@andrewchambers
not sure what you mean
if you have an instance of a C struct in memory somewhere you likely can access it using a c function
saikyun
@saikyun
right, I was just thinking if there was ways to access it without having to create c functions for it
I just to seem to remember that one is able to do something like (:field struct) somehow, but I might be misremembering
ie make the structs less opaque
Zach Smith (subsetpark)
@subsetpark:matrix.org
[m]
Abstract types do expose fields like that (for instance you can call pairs to view the available methods on one) but I wouldn’t necessarily extend that metaphor to anything with a native implementation
MikeBeller
@MikeBeller
Why do some releases of Janet not have full sets of assets associated with them? Specifically 1.15.1 and 1.16.1 only have single zip/gzip files. I ask because Janet playground "update" mechanism downloads janet.c and janet.h from the link https://github.com/janet-lang/janet/releases/vXXXX/janet.[ch] -- but it doesn't exist for 1.16.1 (or 1.15.1 for that matter).
saikyun
@saikyun
@subsetpark what constitutes an abstract type? And is this documented somewhere? :)
2 replies
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.