Why Nim allowing asm stmt at js ?

2024-01-02 Thread rel
The situation seems to be like "no difference between {.importcpp.} and 
{.importjs.}" for Js backend. 

If "{.importcpp.} == {.importjs.}" in js compiler it is confusing why eg. in 
"dom.nim" both pragmas are used.


some MM modes leads to SIGSEGV

2024-01-02 Thread oyster
So bad, my application uses winim to interact with Windows .NET Frameworks 
during reading Excel files( **both** xls and xlsx), as a result there is no 
need to install any Office-like software, for example MS Office, .

I don't know whether there is any other opensource solution, which can be used 
in Nimlang, for reading Excel files or not. Well, actually, I have not found 
such a library at all.

BTW1, WSL is not a solution for end-user, never and forever

BTW2, I have bad experience with GTK decade ago, but of cause on Windows OS. 


some MM modes leads to SIGSEGV

2024-01-02 Thread ThomasTJdev
There are two really good packages for [reading 
xlsx](https://nimble.directory/search?query=xlsx):

  * [xlsx by ringabout](https://github.com/ringabout/xlsx)
  * [xl by khchen](https://github.com/khchen/xl)




some MM modes leads to SIGSEGV

2024-01-02 Thread Calonger
Wrong acyclic ?


Pros and Cons of Use of Dr Oz Vigor Vita CBD Gummies

2024-01-02 Thread ozvigorvita
►❱❱ Item Name: — Dr Oz Vigor Vita CBD Gummies ►❱❱ Utilized For: — Reduces Pain, 
Stress, Anxiety And Sale Now... ►❱❱ Composition ➥ Natural Organic Compound 💯 
►❱❱ Incidental effects: — NA ►❱❱ Rating:— Overall rating: — ⭐ ►❱❱ 
Availability ➥ Online 💲 ➤➤❱❱ Where to Buy ➺ 👉 {Buy Now Here — Click Here}

Official Website@Official Website>>> 


Facebook Page@Facebook Page>>> 
 
 


Dr Oz Vigor Vita CBD Gummies @Dr Oz Vigor Vita CBD Gummies >>> These Dr Oz 
Vigor Vita CBD Gummies are reputable and to keep away from any fraud you must 
buy it from reliable internet site hyperlinks given below. Dr Oz Vigor Vita CBD 
Gummies provide capacity Benefits due to Cannabidiol (CBD), a non-psychoactive 
compound derived from cannabis.

Jimdo Site@Jimdo Site>>>  
 
 
 
 


Group Google@Group Google>>> 
 
 
 
 
 
 
 
 


Weblow@Weblow>>> 

Scoop.It s...@scoop.it Site>>> 


Google Site@Google Site>>> 
 

 

  
 
 

  
 
 

  


Blog Spot@Blog Spot>>> 
 
 
 

 

Medium Site@Medium Site>>> 

 

 

 

 


Gamma Site@Gamma Site>>> 

 

 

 

  

 

ThreadButler - Multithreading with long-running threads that act as "servers"

2024-01-02 Thread mratsim
> Or B) I strip out the long-running threads and just make this an abstraction 
> over status/nim-taskpools that can be used for all kinds of tasks including 
> IO, given that they can send a message back when they're done, which is read 
> from by the main-thread controlling the taskpool. For IO it would be mostly 
> sync-IO that blocks that particular worker-thread until it is done. That 
> would be stripping it down to a pure "Executor-Design" according to the 
> blogpost.

I would say this is more similar to an actor model. For example in Rust land, 
actix builds on top of the Tokio threadpool.

The API is pretty simple: 

Otherwise Pony-lang is a good inspiration and the actor part is simple C: 


Re: studying

I wish you luck. Before creating Weave I did 2 other threadpools (can be seen 
in Weave commit history), but I went from the start with the idea that I'm just 
exploring the field and will likely throwaway everything.

You can see in 0.1 of Weave that I looked deeply into 2 other schedulers and 
reimplemented some until I know enough whether that direction is promising or 
not: 


some MM modes leads to SIGSEGV

2024-01-02 Thread oyster
yes, there are some libs to handle `xlsx`, but what about the old `xls` format

to be frank, I only know the following excel file( **both** xlsx and xls ) 
reading libs which can be used by Nimlang

  * .NET lib, for example NOPI
  * Python lib, for example, Openpyxl for xlsx, xlrd for xls
  * C lib, libxl which is a $ one, and which is the only mature one I know for 
excel file handling




Arraymancer - 2023-12-31 - Overview of longstanding missing features

2024-01-02 Thread mratsim
> Regarding running blas and lapack on windows it seems to me that the 
> situation is a little better now. Download the right dll, place it in the 
> path and it works. Would there be other benefits to reimplementing blas and 
> la pack in nim? Do you have an estimation of how much effort that would 
> require? Do those libraries change a lot over time?

The hardest BLAS function is already implemented and competitive:

  * OpenMP version: 

  * Weave version: 

  * einsum version, slow: 

  * compiler version, differentiable: 
,
 unsure about the speed of this one



> Regarding the switch from OpenMP to one of the native nine thread pop 
> libraries: how hard do you think that would be to do?

It's mostly changing `for i in 0||len-1` to `parallelFor i in 0 ..< len` and 
doing explicit captures.

> Some of the items you mention in the GitHub issue seem pretty hard to do…

Which ones?


why object variants not support same field name ?

2024-01-02 Thread Calonger
What is type of expression command.opts ?


why object variants not support same field name ?

2024-01-02 Thread aiac

type CommandId = enum
  cmdSearch
  cmdDownload

type Command = object
  case id: CommandId
  of cmdSearch:
opts: SearchOpts
  of cmdDownload:
opts: DownloadOpts # Error: attempt to redefine: 'v'



Run


why object variants not support same field name ?

2024-01-02 Thread Isofruit
And note that the type **must** be explicit, no generics allowed. The reason 
for that being that you must know the explicit field **at compileTime** so you 
can link the appropriate procs to it.

Keep in mind that "id" is a runtime field. You can't know at compileTime what 
it'll be.

So if you have


proc doThing(x: SearchOpts) = echo "search"
proc doThing(x: DownloadOpts) = echo "download"

command.opts.doThing()


Run

You **can not know at compileTime** which of these procs you're supposed to 
call here. That means the compiler can not compile your program.


some MM modes leads to SIGSEGV

2024-01-02 Thread Araq
Let me try again:

> Do this mean there is some bug in my code or use libs?

Yes. Potentially in both.

> if there are bugs, how to trace, locate and fix the line(s) in source code?

Setup a sanitizer, review your own code, review your used libraries. Under WSL 
you can use `valgrind`, but then you're in a Linux environment.

Under Linux you can use WINE and `valgrind` to run your Windows program. Maybe. 


Wishlist: Ideal UI library for Nim

2024-01-02 Thread Isofruit
While I actively contribute and yes it is actively being worked on by can.l 
(who is the core behind this really nice idea) and myself, this does not 
fulfill one of the criteria:

> Written in Nim with an idiomatic API and DSLs. Of course. But! It should be 
> compiled to a DLL so that my build times don't suffer. ;-)

Owlkettle is more beautiful GTK bindings, so basically the majority of the code 
being executed is C.


Wishlist: Ideal UI library for Nim

2024-01-02 Thread Angluca





why object variants not support same field name ?

2024-01-02 Thread mratsim
It does if you have the same type


type CommandId = enum
  cmdSearch
  cmdDownload

type Command = object
  case id: CommandId
  of cmdSearch, cmdDownload:
opts: int


Run

Otherwise, there are several RFCs related to variants, sum types and ADTs:

  * 
  * 
  * 
  * 



at the very least.

Also @Araq has been working on a new design of ADTs in the past week.


some MM modes leads to SIGSEGV

2024-01-02 Thread mratsim
Clang + `--passC:-fsanitizer=address --passL:-fsanitizer=address` works fine on 
Windows.


Oz Vigor Vita CBD Gummies: Reviews, Ingredients, & Price!

2024-01-02 Thread ozvigorvitagumi
►❱❱ Item Name: — Oz Vigor Vita CBD Gummies ►❱❱ Utilized For: — Reduces Pain, 
Stress, Anxiety And Sale Now... ►❱❱ Composition ➥ Natural Organic Compound 💯 
►❱❱ Incidental effects: — NA ►❱❱ Rating:— Overall rating: — ⭐ ►❱❱ 
Availability ➥ Online 💲 ➤➤❱❱ Where to Buy ➺ 👉 {Buy Now Here — Click Here}

Official Website@Official Website>>> 


Facebook Page@Facebook Page>>> 
 


Oz Vigor Vita CBD Gummies:- These Oz Vigor Vita CBD Gummies are created by 
using blending a flavored gelatin-like substance with CBD taken from hemp. The 
cannabinoid is just one out of dozens of materials that you can find in hemp. 
However, it’s one of the maximum effective ones, as it without delay affects 
the brain, diminishing your pain sensors, and making you calm and relaxed.

 


Jimdo Site@Jimdo Site>>>

 
 


Group Google@Group Google>>> 
 
 
 
 


Feedback Site@Feedback Site>>> 


Webflow Site@Webflow Site>>> 

Scoop.It s...@scoop.it Site>>> 


Google Site@Google Site>>> 

  

 

 

Blog Spot@Blog Spot>>> 
 
 


Medium Site@Medium Site>>> 

 

 


Gamma Site@Gamma Site>>> 

 

 


Company Site@Company Site>>>  
 


Soundcloud Site@Soundcloud Site>>> 

 

 


Sketchfab Site@Sketchfab Site>>> 

 

 


News@News>>> 


Facebook Page@Facebook Page>>> 
 
 
 
 
 


Other Facebook Page@Other Facebook Page>>>

Facebook 

some MM modes leads to SIGSEGV

2024-01-02 Thread sls1005
> Do this mean there is some bug in my code or use libs?

This means there's some problem associated with pointers, usually a 
nil-derefercing. The bug can either be in your code or be in the lib. It's hard 
to tell as we don't know how you're using it. Some code snippets would be 
helpful. Knowing the version of the compiler you are using would also be 
helpful, as the bug can even be in the compiler. (There's a similar bug on Nim 
1.6.x that affects both ARC and ORC.)

> if there are bugs, how to trace, locate and fix the line(s) in source code?

Perform unit tests, focusing on code that uses pointers with FFI or uses GC'ed 
memory. (Maybe you should mainly focus on the latter as the bug only appears on 
some particular MM modes.) If you have reduced the code to a basic example and 
still getting SIGSEGV, then you probably have found the bug. If you are not 
getting SIGSEGV, run it twice more because that could be a false negative. This 
is at least what I would do.


Maybe nappgui is best cross platform gui lib for nim

2024-01-02 Thread Angluca





Wishlist: Ideal UI library for Nim

2024-01-02 Thread PMunch
Hmm, a very interesting target for a Nim wrapper!


Maybe nappgui is best cross platform gui lib for nim

2024-01-02 Thread Isofruit
As PMunch stated, looks like a nice project to provide bindings for. You could 
do sth. like owlkettle does and put a declarative GUI-DSL on top of that for 
far better ease of use (this is what makes me e.g. prefer the owlkettle 
approach over gintro: I have an explicit immediately visible widget-tree).


Nim Tooling Roadmap

2024-01-02 Thread Omnomnim
This is fantastic news.


Maybe nappgui is best cross platform gui lib for nim

2024-01-02 Thread aiac
Rust egui is very easy to use. Hope nim also has a similar ;-)


Maybe nappgui is best cross platform gui lib for nim

2024-01-02 Thread Araq
Maybe it's not. Missing widgets:

  * HTML view
  * Text editor with syntax highlighting
  * Video player
  * ...



;-)

Can you build these yourself? Yes but then do you want to if the basic text 
height etc is defined by the OS and so you need to test your widget on the 3 
supported OSes...


The nim installer for Windows contains malware

2024-01-02 Thread edreamleo
Thanks to all for your helpful comments.

Several of us in the Leo world are up and running with Nim.


Sum types, 2024 variant

2024-01-02 Thread Araq
Happy New Year!

I'm posting this here as it's not refined enough for an RFC, yet. Feedback 
appreciated.

# Sum types, 2024 variant

In this proposal it is a simple extension to the existing `enum` construct:


type
  Option[T] = enum
of None: discard
of Some: T
  
  Either[A, B] = enum
of Le: A
of Ri: T
  
  BinaryNode = object
a, b: ref Node
  UnaryNode = object
a: ref Node
  
  Node = enum
of BinaryOpr: BinaryNode
of UnaryOpr: UnaryNode
of Variable: string
of Value: int



Run

The new form of an `enum` that uses an `of` syntax is called the "sum enum". 
Constructing an enum branch uses the branch name plus its payload in 
parenthesis. However, `BinaryOpr(BinaryNode(a: x, b: y))` can be shortened to 
`BinaryOpr(a: x, b: y)`, an analogous shortcut exists for tuples.

To access the attached values, pattern matching must be used. This enforces 
correct access at compile-time.

### Simple pattern matching

The syntax `of Branch as x` can be used to unpack the sum type to `x`.


proc traverse(n: ref Node) =
  case n[]
  of BinaryOpr as x:
traverse x.a
traverse x.b
  
  of UnaryOpr as x:
traverse x.a
  
  of Variable as name:
echo name
  of Value as x:
counter += x



Run

`of Branch as variable` is sugar for `of Branch(let variable)`. `of Branch(var 
variable)` is also available allowing mutations to `variable` to write through 
to the underlying enum object.

The syntax `of Branch as x` can later be naturally extended to if statements: 
`if n of BinaryOpr as x` or `if n of Some(var n)`.

### More complex pattern matching

Proposed syntax:


case n
of BinaryOpr(var a, UnaryOpr(let b)) if a == b:
  a = ... # can write-through



Run

### Serialization

There are two new macros that can traverse enums:

  1. `constructEnum` takes in a type `T` and an expression in order to 
construct an enum type `T`.
  2. `unpackEnum` takes in a value of an enum type and an expression in order 
to traverse the data structure.



For example:


type
  BinaryNode = object
a, b: ref Node
  UnaryNode = object
a: ref Node
  
  Node = enum
of BinaryOpr: BinaryNode
of UnaryOpr: UnaryNode
of Variable: string
of Value: int

proc store(f: var File; x: int) = f.write x # atom
proc store(f: var File; r: ref Node) = store r[] # deref `ref`
proc store[T: object](f: var File; x: T) =
  # known Nim pattern:
  for y in fields(x): store y

proc store[T: enum](f: var File; x: T) =
  unpack x, f.store, f.store
  # `unpack` is expanded into a case statement:
  # `case x[]
  # of Val as val: f.store(kind); f.store(val)`
  # ...


proc load[T: enum](f: var File; x: typedesc[T]): T =
  let tmp = f.load[:IntegralType(T)]()
  result = constructEnum(T, tmp, f.load)
  
  # constructEnum is expanded into a case statement:
  # `case tmp
  # of Val: Val(f.load[:BranchType]())`
  # ...



Run


Elite Gummies [Beware Refreshed Warning] Stunning Read First?

2024-01-02 Thread jinauio
Elite Gummies [Beware Refreshed Warning] Stunning Don't Buy Read First? ☛ ☛ 
☛Buy Now Today We Accept Limited Orders☚ ☚ ☚ ☛ ☛ Click Here For Buy☚ ☚ Read 
More..  
 
 
 
 
 
 

 

 

 

 

  
 

 

 

 

 

 

 

 

 

 

  

  
 

 



Maybe nappgui is best cross platform gui lib for nim

2024-01-02 Thread oyster
This GUI lib has a ugly looking


Maybe nappgui is best cross platform gui lib for nim

2024-01-02 Thread nasl
What's so ugly about it? Looks pretty good to me: 



Strange Behavior About Nim 2.0 Destructor

2024-01-02 Thread ringabout
progress: 


Maybe nappgui is best cross platform gui lib for nim

2024-01-02 Thread Isofruit
I agree with that it looks pretty alright. I mean, I'm partial towards a more 
GTK-y look generally, but even then this looks perfectly serviceable. I 
wouldn't mind writing an app in that myself if I weren't slammed with like 5 
other things.


Sum types, 2024 variant

2024-01-02 Thread khaledh-nim
This is great! Looking forward to having this in the language.

Any chance we can have some sugar to avoid declaring a payload object for 
branches? i.e. the following would implicitly declare anonymous types for 
`BinaryOpr` and `UnaryOpr`:


type
  Node = enum
of BinaryOpr: (a, b: ref Node)
of UnaryOpr: (a: ref Node)
of Variable: string
of Value: int


Run


Sum types, 2024 variant

2024-01-02 Thread Araq
It would be a straight-forward extension but I doubt a first implementation 
will have it.


ccal: Calendar with local holidays via ip location

2024-01-02 Thread inv2004
Few updates:

  * Support of personal calendars
  * Custom styles for the ^^^ calendars



smth like:


`$HOME/.config/ccal/myevents.txt``

fgGreen
2024-01-05
2024-06-01
2024-07-01
2024-08-01
styleDim styleUnderscore
2024-06-02
2024-07-31
2024-08-17


Run


karax - embedding stylesheet

2024-01-02 Thread mantielero
Hi, I am playing with an asciidoc parser. Now I am trying to embed a stylesheet 
within an .html created with karax. To do so, I just did something like:


const
  CssDefault* = staticRead("asciidoctor-default.css")

html:
  style:
text CssDefault


Run

I understand that I need to convert some characters from the CSS into something 
that do not mess with the HTML.

Is there a function that can do that for me?


Maybe nappgui is best cross platform gui lib for nim

2024-01-02 Thread mantielero
In that regard, I think [lvgl](https://lvgl.io/) is a better option (working 
even on embedded). I did a proof of concept wrapper for it some time ago: 



ccal: Calendar with local holidays via ip location

2024-01-02 Thread dwhall256
Country code is an ISO standard. [Wikipedia has a 
summary](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes). There 
are two sizes of country codes: two-character and three-character.


State of fidget

2024-01-02 Thread treeform
Sorry, I stopped developing fidget for a while to focus on low level foundation 
libraries such as pixie, windy, boxy, bumpy, vmath, etc...

Making a whole UI toolkit from scratch is a lot of work for one person. 


Sum types, 2024 variant

2024-01-02 Thread ElegantBeef
The biggest issue I see is the usage of `enum` now makes it so any code that 
expects a `enum` typeclass has to delimit three different types of `enum` 
(OrdinalEnum, HoleyEnum, and SumEnum). Consider `parseEnum` it's constrained to 
the typeclass but obviously will only work on the numeric enums(Even your 
examples use a generic constraint that would not make sense for numeric enums). 
I would argue to use `object` as it does not conflate an ordinal type to a 
record type, a builtin typeclass then could be made named `SumObject` for this 
specific construct.


The nim installer for Windows contains malware

2024-01-02 Thread dwhall256
I had my IT dept submit a false-positive report last year. The immediate 
work-around was to install nim and write my nim source in our designated 
virus-scan-exclusion path.

P.S. What's "the Leo world" ?


Sum types, 2024 variant

2024-01-02 Thread ASVI
use the typetraits. SumEnum will most likely be added to it


Understanding an address sanitizer message for a memory leak caused by global dispatcher (?)

2024-01-02 Thread Isofruit
Hello everybody, I am still working on threadButler and based on suggestions 
from mratsim and leorize am starting to take a look at it through various tools 
to look for memory leaks etc.

I am currently trying to wrap my head around using [address 
sanitizers](https://github.com/google/sanitizers/wiki/AddressSanitizer#using-addresssanitizer)
 which should help with figuring out some memory things (another is 
valgrind/heaptrack).

I am... unsure how to interpret some of the messages so I would like to ask for 
some interpretation help here, as this seems to go _far_ deeper than I have any 
level of insight to.

 Setup

I had an [example 
ready](https://github.com/PhilippMDoerner/ThreadButler/blob/add-loonyqueue-support/examples/ex_stdinput.nim)
 and ran it with:

`nim r --cc:clang --mm:arc -d:release --debugger:native -d:useMalloc 
--passc:-fsanitize=address --passl:-fsanitize=address examples/ex_stdinput.nim`

 Output

The biggest memory leak


Indirect leak of 57352 byte(s) in 1 object(s) allocated from:
#0 0x55c1436e1de1 in __interceptor_calloc 
(/home/philipp/.cache/nim/ex_stdinput_r/ex_stdinput_DD41B6791D32A0B925C6208AC76777EEE30185AD+0x116de1)
 (BuildId: e7b10045252e22912e59f7086d94388eca9eb9eb)
#1 0x55c143733a35 in newSeqPayload 
/home/philipp/.choosenim/toolchains/nim-2.0.2/lib/system/seqs_v2.nim:44:767
#2 0x55c14373d8f4 in newSeq__pureZasyncdispatch_u1664 
/home/philipp/.choosenim/toolchains/nim-2.0.2/lib/system/seqs_v2.nim:140:2
#3 0x55c14373d8f4 in newSeq__pureZasyncdispatch_u1660 
/home/philipp/.choosenim/toolchains/nim-2.0.2/lib/system.nim:631:2
#4 0x55c143754462 in newSelector__pureZasyncdispatch_u1639 
/home/philipp/.choosenim/toolchains/nim-2.0.2/lib/pure/ioselects/ioselectors_epoll.nim:101:196
#5 0x55c143759bf1 in newDispatcher__pureZasyncdispatch_u1634 
/home/philipp/.choosenim/toolchains/nim-2.0.2/lib/pure/asyncdispatch.nim:1209:23
#6 0x55c143758ee8 in getGlobalDispatcher__pureZasyncdispatch_u2349 
/home/philipp/.choosenim/toolchains/nim-2.0.2/lib/pure/asyncdispatch.nim:1237:39
#7 0x55c143777f97 in serverProc__ex95stdinput_u2576 
/home/philipp/dev/threadbutler/src/threadButler.nim:72:2


Run

Now I am mildly confused by this output. It refers to line 72 of my own 
threadButler.nim doing... _something_ that causes a leak.

The code it refers to is this (line 72 can be found at the bottom of the 
codeblock):


proc runServerLoop[Msg](data: Server[Msg]) {.gcsafe.} =
  mixin routeMessage
  
  while IS_RUNNING:
var msg: Option[Msg] = data.hub.readMsg(Msg)
try:
  while msg.isSome():
{.gcsafe.}:
  routeMessage(msg.get(), data.hub)

msg = data.hub.readMsg(Msg)

except KillError:
  break

except CatchableError as e:
  error "Message caused exception", msg = msg.get()[], error = e.repr

if hasPendingOperations():
  poll(0)
else:
  sleep(data.sleepMs)

proc serverProc*[Msg](data: Server[Msg]) {.gcsafe.} =
  mixin runServerLoop
  data.startUp.execEvents()
  
  runServerLoop[Msg](data) ## This is line 72
  
  data.shutDown.execEvents()


Run

 My current understanding

My guess is that the nim-compiler saw the `poll` call in `runServer` and 
implicitly called `getGlobalDispatcher` which implicitly spawned said global 
dispatcher which somehow causes a memory leak.

Based on that my questions:

  * 1 Is this _actually_ a leak or is this an unavoidable false positive where 
one should just tell address sanitizer [somehow to ignore 
it](https://github.com/google/sanitizers/wiki/AddressSanitizer#turning-off-instrumentation)?
  * 2 If it is a leak, what is supposed to be done here?




Sum types, 2024 variant

2024-01-02 Thread morturo
This is great! I've been waiting for something like this for a long time.


Sum types, 2024 variant

2024-01-02 Thread Isofruit
I would agree on the enum front, not based on any of the points beef made but 
more fundamentally:

The way this looks to me, the naive and unknowing user, is that it's a 
different of writing object variants where you directly write the enum into the 
object variant.

However what I'm mildly stuck on is how you those "enums-in-variants" interact 
with stuff like e.g. `parseEnum`


Sum types, 2024 variant

2024-01-02 Thread ASVI
Object variants will be obsolete. Deprecation warnings and the messages in the 
documentation will prevent this


Sum types, 2024 variant

2024-01-02 Thread ElegantBeef
The issue is that there is code that presently works that only works with 
numeric `enum`s. By accepting both you now have code that appears like it 
should work but will result in instantiation errors. By all accounts of current 
Nim`SumEnum` is a specialization of `object` not `enum`, you cannot use them in 
a `set`, `range`, or as an `array` index type. So while new code can use 
`SumEnum` old code still exists and should not misrepresent what it works on.


Sum types, 2024 variant

2024-01-02 Thread Araq
Good gotcha, reusing the `enum` typeclass for sum enums will be too confusing. 
Back to `case`?


type
  Option[T] = case
of None: discard
of Some: T
  
  Either[A, B] = case
of Le: A
of Ri: T
  
  BinaryNode = object
a, b: ref Node
  UnaryNode = object
a: ref Node
  
  Node = case
of BinaryOpr: BinaryNode
of UnaryOpr: UnaryNode
of Variable: string
of Value: int



Run


Sum types, 2024 variant

2024-01-02 Thread Isofruit
Makes perfect sense to me. In fact, I like this a fair bit more than default 
object variants because they are a special type of object and by using case 
instead of object that is immediately visible!


Sum types, 2024 variant

2024-01-02 Thread Araq
I didn't check the grammar but


proc store[T: case](f: var File; x: T)



Run

looks easy enough to support.


Sum types, 2024 variant

2024-01-02 Thread ElegantBeef
Though since `case` also can be used for flow control I assume the typeclass 
would also not be `case` as that'd make parsing more complex?


Understanding an address sanitizer message for a memory leak caused by global dispatcher (?)

2024-01-02 Thread Isofruit
I guess in lieu of a better question:

Does anybody actually use address-sanitizers or valgrind or heaptrack and 
eradicates potential memory leaks to the point that _nothing_ shows up while 
they run?

The repeated attempts I've made at using these tools always lead me to areas 
where I never understood what the supposed solution is. Like a memory leak 
reported by heaptrack from `readLine`. That one just makes me assume that 
heaptrack is faulty because I trust the output is getting accurately collected.

I'm developing similar vibes for address sanitizers that they contain a decent 
chunk of "false positives".


Sum types, 2024 variant

2024-01-02 Thread ASVI
And for guard better make new where keyword.


Sum types, 2024 variant

2024-01-02 Thread ASVI
Maybe better instead of enum or case name it union or variant. But case is 
already good


Sum types, 2024 variant

2024-01-02 Thread j-james
This looks mostly fine to me. I'd rather these be called `union` but it's a 
minor complaint.

The distinction between mutable and immutable bindings seems irrelevant. Why 
not have mutability follow the mutability of the matched-upon object? I would 
much prefer to do away with `let`, `var`, and `as` and just have ex. `of 
BinaryOpr(a, UnaryOpr(b)) if a == b` but understand it breaks existing `case` 
semantics...

I would suggest also overloading `of` to function in `while` statements:


var optional = Some(0)

if optional of Some as i:
  echo "optional is inhabited!"

while optional of Some as i:
# optional of Some(var i):
if i > 9:
echo "Greater than 9, quit!"
optional = None
else:
echo fmt"`i` is `{i}`. Try again."
optional = Some(i + 1)


Run

The complex / structural pattern matching looks nice, and could be implemented 
later for the sake of getting this in the language quickly (or as a macro! 
possibly). It would probably have to reject inconsistent bindings to work with 
the way matching multiple enum variants at once currently works:


case foo
# rejected! there is not a binding b in all branches:
of BinaryOpr(var a, UnaryOpr(let b)), UnaryOpr(var a) if a == b`
# allowed! both a and b's types are consistent:
of BinaryOpr(var a, UnaryOpr(let b)), BinaryOpr(var a, let b) if a == b:
  discard


Run


karax - embedding stylesheet

2024-01-02 Thread mantielero
My bad. I was comparing the files wrong. In any case, for the record:

  * `text CssDefault` would convert `/`, `<` and things like that `<` and so 
on.
  * `verbatim CssDefault`: would not convert them. This is what I was needing.




Sum types, 2024 variant

2024-01-02 Thread konsumlamm
It's great that proper sum types are finally coming! Though I would prefer 
syntax like in 
, which is 
more ergonomic IMO:


type
  Option[T] = enum
of None()
of Some(T)
  
  Either[A, B] = enum
of Le(A)
of Ri(T)
  
  Node = enum
of BinaryOpr:
  a, b: ref Node
of UnaryOpr:
  a: ref Node
of Variable: string
of Value: int


Run

IME, separate types for the variants are usually not needed (and this syntax 
could define them implicitly, if needed). Implicitly shortening patterns also 
feels like a bad design.


ccal: Calendar with local holidays via ip location

2024-01-02 Thread inv2004
Looks like 3ch code is not supported by upstream calendar api


Nim Compiling to js

2024-01-02 Thread mardon86
How can we transpile nim to js in the browser on the fly, so that we can write 
nim right in the browser ?


How Can I Ensure Backward Compatibility with Destructors in Nim 2.0?

2024-01-02 Thread Ward
Based on information from , I believe a 
more suitable approach would be to use `when defined(nimAllowNonVarDestructor) 
and not defined(gcRefc)`


Strange Behavior About Nim 2.0 Destructor

2024-01-02 Thread Ward
I've observed that certain code using `when defined(nimAllowNonVarDestructor)` 
to choose the destructor ends up using the wrong version for `refc`.




Wishlist: Ideal UI library for Nim

2024-01-02 Thread oyster
it is nonsense if we do not name the widgets we hope to use in GUI applications

button, label, text input are common widgets in most of the UI lib.

however, I usualy use table/cell to address/edit data, though there is no huge 
data in my case. Table, on the other hand, is missing in many libs, as a 
result, I will not use such a lib


Sum types, 2024 variant

2024-01-02 Thread Araq
> Implicitly shortening patterns also feels like a bad design.

What do you mean?


Sum types, 2024 variant

2024-01-02 Thread Araq
> but understand it breaks existing case semantics...

While that is a problem, the bigger problem with your proposed syntax is the 
inherent ambiguity between "new declaration" and "bind to existing symbol".


Sum types, 2024 variant

2024-01-02 Thread arnetheduck
For those thinking of this as a special case of an object variant, it is .. 
here's an equivalent "desugaring" syntax:


type ExtraEither[A, B] = object
   field: int
  case _: _
  of Le:
_: tuple[le: A]
  of Ri:
_: tuple[ri: B]


Run

It is roughly equivalent, in the above enum notation, to:


ExtraEither[A, B] = enum
of Le:
   tuple[field: int, le: A]
of Ri:
  tuple[field:  int, ri: B]
  

Run

This highlights the important properties and differences in how the sum type is 
special over the object variant, similar to how a scalar type like int is 
special compared to an `array[1, int]`:

  * it has only one discriminator / tag
  * that tag (and potentially its type) is anonymous and/or implicit
  * each branch has one tuple of "contents" which may be empty



The above two points are important for thinking about the tag type in terms of 
the ergonomics, assumptions and operations that it enables, compared to an 
object variant (just like array-of-1 is a convenient special case in the 
language):

  * We can construct an instance with incomplete knowledge about the "other" 
branches - for `Either[A, B]`, I can construct the Either knowing only one of A 
and B - from the example, `Either.Le(42, false)` must be implicitly convertible 
to `Either(bool, _)` with the B left unspecified at the instantiation point - 
this is an important feature!
  * We can construct pattern matchers that are exhaustive and don't know the 
name or type of the tag field
  * These pattern matches can assume that each branch is fully defined and can 
offer syntax centering on the fact that the branch "members" are contained in a 
single tuple-like construct



In the example, I threw in a little conveniece, ie the ability to add "global" 
fields that apply to all branches - these do not interfere with the above 
points about how the enum type is more specialized than an object variant.

Thinking about it this way, we could potentially integrate it better with the 
language too. Nim for example allows constructing arrays where the "length" is 
a type, ie `array[bool, int]` \- this is in part why I don't feel the `enum` 
proposal fully embraces and integrates with "the rest" \- I'd like to be able 
to create sum types whose branches are `bool` because that is an important 
player / special case in this field: it limits the sum type even further by 
saying there are exactly two branches (which in generic / macro code could be 
treated special). One can also easily imagine a sum type over a `static int` 
with that many branches, each identified positionally, without losing the above 
3 properties that makes the sum type "special".


Maybe nappgui is best cross platform gui lib for nim

2024-01-02 Thread Angluca
lvgl looks like well. 


Wishlist: Ideal UI library for Nim

2024-01-02 Thread Angluca
https://github.com/lvgl/lvgl