get object field by variable

2024-05-05 Thread xigoi
Depending on the use case, you may want to use a table.

Issue with C array

2024-05-05 Thread PMunch
I tried to explain this in my reply in the Futhark issue, but I was on my way to the airport so the answer was a bit brief. What you're seeing in `AV_CHANNEL_LAYOUT_MASK` is an object constructor, however since C doesn't have typed macros it doesn't tell us which object its constructing for. The

Nim in university context?

2024-05-05 Thread mszs
I think I'll go with bonus points for projects done using Nim and it's ecosystem. While I believe that they will benefit from trying out Nim even without, the bonus points are to give them a kind of cushion to offset time invested getting up to speed with Nim.

get object field by variable

2024-05-05 Thread PMunch
I think the question was how you can access a field in an object through a variable holding the name of the field. Unfortunately (at least in this case, most often it is very fortunate) Nim is a statically typed compiled language, so the names of fields aren't really accessible at runtime. You

get object field by variable

2024-05-05 Thread 4n0n4me
it's possible like this (not tested) proc `[]`(obj: JsObject, key: string): ??? {.importjs: "#[#]".} Run but you don't know the return type

Issue with C array

2024-05-05 Thread sls1005
In the C language I know, `{` and `}` are used to form an initializer for either an array or a struct, while `[` and `]` are not used in initializers, but can be used to form an array type. But yes, `AVChannelLayout` (or `struct AVChannelLayout`) seems to be a struct-type, so you may need to wra

Issue with C array

2024-05-05 Thread mantielero
Thanks for the clarification. I will also need to do something like suggested here:

get object field by variable

2024-05-05 Thread anter003
Can I get object's field value by variable? In javascript I can do something like this: var obj = { a: 10, b: 20 } var c = "a" console.log(obj[c]) Run

Issue with C array

2024-05-05 Thread demotomohiro
If I understand correctly, `AV_CHANNEL_LAYOUT_MASK` is a macro to initialize `struct AVChannelLayout`. In C language, `[` and `]` are used to initalize arrays and `{` and `}` are used to initialize struct type variables.

I Have Created a Kinda Logging Solution :)

2024-05-05 Thread enthus1ast
I use chronicles in basically every "non toy" app I write (also cligen for params and sim for automatic config parsing)

I Have Created a Kinda Logging Solution :)

2024-05-05 Thread brainproxy
Nice work! I don’t have much to add re: the other replies you’ve received but wanted to mention nim-chronicles It’s a robust logger written in Nim and could make for an interesting study as you learn more about the language.

Issue with C array

2024-05-05 Thread mantielero
I am trying to wrap ffmpeg. I am having an issue with a C array. The issue is with the following code [libavutil/channel_layout.h](https://github.com/FFmpeg/FFmpeg/blob/release/6.1/libavutil/channel_layout.h#L372-L390). I have tried with c2nim, futhark and nimterop without success. I understand

malebolgia threads deadlock when trying to synchronize them.

2024-05-05 Thread planetis
Nevermind, the TSan error was the clue, making submitinfo outside the awaitAll block fixed it.

I Have Created a Kinda Logging Solution :)

2024-05-05 Thread pp
Just a note: I think it makes no sense in the except branch to try to write to the stream again. If it failed just use echo like you did.

Can I use std/json to serialize objects in a Table?

2024-05-05 Thread ninovanhooff
I made a modification to the types to use a seq instead of a table: import playdate/api import std/json import std/options import std/sequtils import utils import shared_types let kFileReadAny*: FileOptions = cast[FileOptions]({kFileRead, kFileReadDa

Can I check if a proc is async at compileTime without a macro?

2024-05-05 Thread blackmius
i think the problemis that you actually trying to call function and not check the procedure const a = typeof(complete()) maybe you somehow need to do it using macros and check ast

Can I use std/json to serialize objects in a Table?

2024-05-05 Thread ninovanhooff
Thanks for the suggestion, but adding the tables import didn't help