!EtGqjSRNQoJCbpCJSF:matrix.org

Nim programming language

4060 Members
Official Matrix channel for the Nim programming language. This channel is bridged with our main Discord and Gitter channels.62 Servers

Load older messages


SenderMessageTime
26 Nov 2022
@_discord_610710352254205952:t2bot.iojos i want the equality operator to check deep equality of each field, like value types 18:30:30
@_discord_610710352254205952:t2bot.iojos does anybody know where i can find a macro that does that 18:30:38
@_discord_610710352254205952:t2bot.iojos i found this discussion but it doesn't look like anyone here knows, was last updated 2 years ago 18:33:28
@_discord_610710352254205952:t2bot.iojos https://forum.nim-lang.org/t/6781 18:33:29
@_discord_483386797276004382:t2bot.ioAfonso Lima joined the room.18:40:03
@mantielero-5c5c719ed73408ce4fb729cc:gitter.immantielero (mantielero) Hello 18:58:06
@mantielero-5c5c719ed73408ce4fb729cc:gitter.immantielero (mantielero) I am trying to do the following c++ in nim:
shared_ptr<AbstractState> Water(AbstractState::factory("HEOS","Water"));
18:58:54
@mantielero-5c5c719ed73408ce4fb729cc:gitter.immantielero (mantielero) I wrapped factory that returns ptr AbstractState. 18:59:37
@mantielero-5c5c719ed73408ce4fb729cc:gitter.immantielero (mantielero) Then I am trying to use cppstl. The came up with:
var water = cast[CppSharedPtr[AbstractState]]( factory(initCppString("HEOS"), initCppString("Water")) )
19:00:28
@mantielero-5c5c719ed73408ce4fb729cc:gitter.immantielero (mantielero) It is not working. 19:00:50
@mantielero-5c5c719ed73408ce4fb729cc:gitter.immantielero (mantielero) The error that I got is:
@mas.nim.cpp:155:86: error: use of deleted function 'NimMainModule()::<unnamed union>::<constructor>()'
  155 |         union { CoolProp::AbstractState* source; TY__zs5mvwo1JQsJieQJU8S19bg dest; } LOC1;
19:02:25
@mantielero-5c5c719ed73408ce4fb729cc:gitter.immantielero (mantielero) The c++ generated code:
    union { CoolProp::AbstractState* source; TY__zs5mvwo1JQsJieQJU8S19bg dest; } LOC1;
    nimfr_("as", "/home/jose/src/nimlang/coolprop.nim/src/as.nim");
    nimln_(37, "/home/jose/src/nimlang/coolprop.nim/src/as.nim");
    std::string T2_ = initCppString__OOZOOZOOZOOZOnimbleZpkgsZcppstl4548O52O49ZcppstlZstd95string_467(((NimStringDesc*) &TM__2oQmfdzNe0gThjWdrloW8g_2));
    std::string T3_ = initCppString__OOZOOZOOZOOZOnimbleZpkgsZcppstl4548O52O49ZcppstlZstd95string_467(((NimStringDesc*) &TM__2oQmfdzNe0gThjWdrloW8g_3));
    LOC1.source = CoolProp::AbstractState::factory(T2_, T3_);
    water__as_13 = LOC1.dest;
    popFrame();
19:03:34
@_discord_288750616510201856:t2bot.iodemotomohiro If this is what you want, you don't need to use macro:
https://play.nim-lang.org/#ix=4gXm
But it is not much tested.
It might fails in more complicated types.
19:49:43
@_discord_180601887916163073:t2bot.ioPhil Okay, adding links for nimble docs is kind of a massive pain in the keister 20:10:17
@reversem3:matrix.orgnixfreakCan you use .to_upper() to only Capitalize the first Letter ? Or would you have to do a case statement or using if logic ?20:20:49
@_discord_268111216277323779:t2bot.ioJessa woo, made my own color printing thing for terminals 20:23:42
@_discord_268111216277323779:t2bot.ioJessaunknown.png
Download unknown.png
20:23:45
@reversem3:matrix.orgnixfreakCool , https://nim-lang.org/docs/strutils.html#toUpperAscii,char nm 20:24:29
@_discord_772217344680001556:t2bot.iowick3dr0se would std/os walkDir be the best route to get directory content. will eventually need to do something for each file returned 20:25:49
@_discord_772217344680001556:t2bot.iowick3dr0se You could use ANSI escape sequences as well. Would be neat to see this implemented in Nim. I did this script in BASH to output possible VT100 color sequences 20:28:28
@_discord_772217344680001556:t2bot.iowick3dr0se * You could use ANSI escape sequences as well. Would be neat to see this implemented in Nim. I did this script in BASH to output possible VT100 color sequences

_out(){
    printf "\e[1;40;97m%s\e[0m\n" "$1"
}

4bit() { # 7 colors
  printf '\e[1;%s%sm%s%s\e[0m' \
    "$1" "$i" "$1" "$i"
}

8bit() { # 256 colors
  printf '\e[%s8;5;%sm%s\e[0m' \
    "$1" "$i" "$i"
}

_out '4-bit ANSI escape sequence'
_out 'Usage: \e[1;??m .. \e[0m'
for i in {0..7} ; do
    4bit 3 # forground
    4bit 4 # background
    4bit 9 # foreground
    4bit 10 # background
done

printf '\n\n'
_out '8-bit ANSI escape sequence'
_out 'Usage: \e[?8;5;???m .. \e[0m'
for i in {0..256} ; do
    8bit 3 # forground
    8bit 4 # background
done
20:28:44
@_discord_268111216277323779:t2bot.ioJessa yes, that's what i'm using 20:28:51
@_discord_772217344680001556:t2bot.iowick3dr0se Well maybe that can be some help then 20:29:18
@_discord_268111216277323779:t2bot.ioJessa help for what lol?
i'm using ANSI escape sequences in the backend
20:29:45
@_discord_772217344680001556:t2bot.iowick3dr0se Outputting them more dynamically instead of just creating variables for each color code 20:30:07
@_discord_709044657232936960_pbotfullerton=5b=49=52=43=5d:t2bot.iopbotfullerton[IRC]#0000 In case anyone else runs into this, I wasn't able to get nim-jwt to compile because of a bunch of errors in the crypto.nim file. bearssl-nim changed their API slightly in June and nim-jwt hasn't been updated to reflect that. Using a bearssl-nim commit before June 2022 makes it work. 20:31:14
@_discord_772217344680001556:t2bot.iowick3dr0se I output 273 colors with only a few printf calls. It can be streamlined to accept parameters easily 20:31:18
@_discord_268111216277323779:t2bot.ioJessa i'm not 20:31:28
@_discord_268111216277323779:t2bot.ioJessa i'm allowing rgb & hex 20:31:32
@_discord_268111216277323779:t2bot.ioJessaimage.png
Download image.png
20:31:42

There are no newer messages yet.


Back to Room List