00:44:12 | NimBot | Araq/Nimrod devel 6550f96 Bódi Balázs [+1 ±0 -2]: fix #1065 |
00:44:12 | NimBot | Araq/Nimrod devel 2da7ad8 Varriount [+1 ±0 -2]: Merge pull request #1139 from bbodi/devel... 2 more lines |
01:17:06 | * | Demos_ joined #nimrod |
01:18:33 | Varriount | dom96: How would you like the different concatenation behavior expressed? |
01:19:17 | * | xenagi quit (Quit: Leaving) |
01:20:08 | * | superfunc joined #nimrod |
01:25:15 | Varriount | dom96: Er, disregard that. |
01:28:54 | * | Demos_ quit (Read error: Connection reset by peer) |
01:32:05 | NimBot | Araq/Nimrod devel 61dfe9f Clay Sweetser [+2 ±0 -1]: Revert "Merge pull request #1139 from bbodi/devel"... 3 more lines |
01:32:05 | NimBot | Araq/Nimrod devel 936eaa6 Varriount [+2 ±0 -1]: Merge pull request #1155 from Varriount/revert-bbodi/devel... 2 more lines |
01:36:03 | Varriount | dom96: Feel free to yell at me. I deserve it. :| |
01:39:10 | * | Skrylar joined #nimrod |
01:46:31 | reactormonk | Varriount, that's why I never merge my own pullrequests ;-) |
01:47:04 | reactormonk | it's the multiple-eyes principle. |
01:57:30 | BitPuffin | yeah that's a really good way to dev |
01:58:51 | reactormonk | BitPuffin, I tend not to write too much code, but I accept one or another PR |
02:02:16 | * | q66 quit (Quit: Leaving) |
02:05:09 | BitPuffin | reactormonk: well it's important to have someone review PRs |
02:06:48 | * | superfunc quit (Ping timeout: 240 seconds) |
02:06:55 | reactormonk | BitPuffin, I just run over them regularly and accept what I deem good and within my domain |
02:08:35 | BitPuffin | reactormonk: yeah :D |
02:17:27 | reactormonk | hmm, the tester fails with Error: unhandled exception: No such file or directory [EOS] |
03:31:56 | * | brson joined #nimrod |
03:42:20 | * | brson quit (Ping timeout: 252 seconds) |
03:43:15 | * | brson joined #nimrod |
03:56:10 | * | brson quit (Ping timeout: 276 seconds) |
03:59:20 | * | bbodi joined #nimrod |
04:08:04 | * | brson joined #nimrod |
04:24:31 | bbodi | dom96: https://github.com/Araq/Nimrod/issues/1065 I checked the python implementation, and there is not any feature there you mentioned. Moreover, I find it a semantically wrong idea. |
04:24:58 | bbodi | If "/foo?test=4&test2=5" url is used, that means you want to visit "foo" with the given param |
04:25:26 | bbodi | "/bar?q=123", here the case is sam,e you want to visit bar with q=123 |
04:26:18 | bbodi | It does not make any sense to concatenate these two totally different things (visiting two different place with their own param), and generating an url with the concatenation of the pathes and using the union of the parameters |
04:26:40 | bbodi | can you give me an example from the real life, when it could be a useful feature? |
04:28:16 | * | bjz joined #nimrod |
04:37:16 | fowl | bbodi, hi, i made WhiteStag compile on linux but the FPS is dreadful, it looks like you are redrawing after handling events |
04:39:00 | fowl | is that right? |
04:39:49 | bbodi | I think it is caused by a View who are mark himself as modified when some event occurs, like eventTick, which occurs automatically in a second. The statusline View do that. |
04:40:28 | bbodi | moreover, StatusLine is modified by every mouse moving event |
04:40:44 | bbodi | PHelpLine, sorry, not statusline |
04:41:58 | bbodi | But i think the FPS should not be so low, the count of redrawing is much lower than it would be in a game |
04:42:21 | bbodi | and thanks a lot for your work |
04:42:29 | fowl | why is the call to swapBackBuffer inside view.executeView |
04:43:32 | bbodi | its the "main loop", i have to swap buffers somewhere |
04:46:57 | fowl | bbodi, but executeView is called for events, not used like a main loop (selectbox.handleItemSelection, window.windowHandleEvent) |
04:47:34 | fowl | oh i see, you use it to block the process for things like opening a file dialog |
04:47:49 | bbodi | you are right, yes |
04:48:05 | bbodi | it becomes the new "main loop" while it is executing |
04:49:58 | bbodi | As I see, you make the project compile on linux by removing clipboard functionality |
04:50:17 | fowl | im looking for a solution |
04:50:34 | bbodi | Ok |
04:50:54 | fowl | too bad this isnt available for 1.2 http://wiki.libsdl.org/SDL_GetClipboardText |
04:51:09 | bbodi | yes, I couldnt use it on windows too |
04:51:29 | fowl | what, sdl2? |
04:52:33 | bbodi | with SDL 2 I had some strange bug and behavior and the early stage of the development, so I stay with SDL 1. But I think the rendering engine is well separated, so it is very easy to replace |
04:52:48 | bbodi | moreover, I will to an engine that use simple console functionality without SDL |
04:53:12 | bbodi | but I have some feature Idea, which for I need SDL, like resizable and transparent View-s |
05:08:08 | * | brson quit (Ping timeout: 252 seconds) |
05:08:16 | * | brson joined #nimrod |
05:29:52 | fowl | bbodi, im going to try to think of how to fix it within your design |
05:31:20 | bbodi | fix what? :) |
05:31:24 | fowl | bbodi, traditionally you would clear all the pending events, draw, then sleep for a time to make the framerate stable |
05:31:34 | fowl | bbodi, the main loop |
05:32:05 | fowl | it might not seem like a problem but my cpu goes up to 100% when im moving the mouse around or hitting keys |
05:32:27 | bbodi | check sdlengine.nim |
05:32:32 | bbodi | readSdlEvent |
05:32:45 | bbodi | that function contains this: sdl.Delay(10) |
05:34:40 | fowl | that runs when there are no events |
05:35:38 | * | brson quit (Ping timeout: 240 seconds) |
05:36:12 | bbodi | measure twice, cut once. I will introduce a new Window that will be available for any application. That window will contains some measurement numbers like the number of different events, and logging |
05:36:44 | fowl | heh |
05:38:20 | fowl | bbodi, you dont see it? when you move the mouse around and the cursor pos starts to lag? i run a task monitor in the background and it goes up to 100% when im moving around the mouse, then when i stop giving it events it slows down (thats when the sdl.delay() is in effect) |
05:40:22 | bbodi | my CPU runs on 12% always. But maybe I have a strong machine. Thanks for your observation! |
05:41:24 | bbodi | I put the SDL.delay to the pollEvent method, right after whule true statement. Try it out please |
05:46:15 | * | brson joined #nimrod |
05:46:34 | fowl | bbodi, that will put the delay after each event still |
05:48:36 | * | Demos quit (Read error: Connection reset by peer) |
05:52:12 | fowl | bbodi, i'll play with it tomorrow, ill probably add a user event to act as the draw timer |
06:09:47 | fowl | good night |
06:12:17 | * | bbodi quit (Ping timeout: 264 seconds) |
07:16:35 | Araq | Varriount: correct (about the new_comment_handling). somebody needs to check it doesn't break the documentation generator in a subtle way. |
07:16:59 | Araq | and then it still needs a deprecation path to allow for: |
07:17:02 | Araq | else: |
07:17:12 | Araq | # comment as a statement suffices |
07:20:20 | * | brson quit (Ping timeout: 252 seconds) |
07:35:13 | * | seertaak joined #nimrod |
07:35:36 | seertaak | good morning everyone |
07:36:37 | seertaak | question: how can I make a nimrod proc visible from C code? |
07:37:14 | seertaak | e.g. C code should expect a function with signature: void(void *, void *) |
07:37:41 | seertaak | hmmm looks like I may be here a bit early ;) |
07:37:51 | * | brson joined #nimrod |
07:51:26 | * | brson quit (Ping timeout: 255 seconds) |
07:53:15 | * | brson joined #nimrod |
08:19:48 | * | seertaak quit (Ping timeout: 240 seconds) |
08:53:52 | * | brihat1 joined #nimrod |
08:53:52 | * | brihat joined #nimrod |
08:53:57 | * | brihat quit (Client Quit) |
08:54:00 | * | brihat1 quit (Client Quit) |
09:03:32 | * | daharon joined #nimrod |
09:07:45 | * | brihat joined #nimrod |
09:07:45 | * | brihat1 joined #nimrod |
09:07:45 | * | brihat1 quit (Client Quit) |
09:07:47 | * | brihat quit (Client Quit) |
09:13:16 | * | [1]Endy joined #nimrod |
09:15:33 | * | io2 joined #nimrod |
09:19:04 | * | Ycros left #nimrod (#nimrod) |
10:09:15 | * | brson quit (Ping timeout: 276 seconds) |
10:13:50 | Araq | hi daharon welcome |
10:16:53 | * | nande quit (Remote host closed the connection) |
10:19:53 | * | Matthias247 joined #nimrod |
10:22:03 | milosn | morning |
10:22:05 | milosn | hi Araq |
10:22:19 | Araq | hi |
10:23:37 | milosn | tell me how does it work for module which are impure and require external libs to work ... for example 're' module |
10:24:26 | milosn | i assume when i compile the binary which i want to deploy ... the development environment and target environment need to match |
10:24:37 | * | daharon left #nimrod ("Leaving") |
10:24:38 | milosn | in this case PCRE needs to match on both? |
10:25:07 | milosn | is that how it works? |
10:28:18 | Araq | hm? |
10:29:34 | milosn | in the module index it says that some modules, like 're' depend on external libraries in this case PCRE |
10:29:51 | milosn | i just wonder how it works when i want to deploy binary which needs those |
10:30:26 | Araq | well you better ship pcre.dll with your .exe |
10:30:38 | Araq | on linux libpcre.so is around anyway |
10:30:55 | milosn | its linux env |
10:30:59 | Araq | re simply imports pcre which wraps the DLL |
10:31:11 | milosn | no dll-s and exe-s :) |
10:31:13 | Araq | and the DLL is loaded via dlsym |
10:31:23 | Araq | note: I use DLL for lib*.so too |
10:31:41 | Araq | because it's easier to type and the term lib*.so makes no sense |
10:31:55 | Araq | bbl |
10:31:59 | milosn | so its safe to say, if my binary is using 're' module ... target env should have libpcre someplace |
10:32:03 | milosn | and it should work? |
10:32:11 | milosn | oke thanks |
10:37:36 | dom96 | 'morning |
10:45:15 | dom96 | Nice of BurntSushi to mention Nimrod in his Rust compile-time regex blog post. |
10:45:39 | dom96 | I wonder why he decided to make the implementation in Rust instead of Nimrod. |
11:12:46 | * | [2]Endy joined #nimrod |
11:15:12 | * | [1]Endy quit (Ping timeout: 240 seconds) |
11:34:03 | * | io2 quit () |
11:36:45 | Araq | milosn: yes, exactly |
12:02:06 | * | bbodi joined #nimrod |
12:06:56 | * | q66 joined #nimrod |
12:06:56 | * | q66 quit (Changing host) |
12:06:56 | * | q66 joined #nimrod |
12:08:18 | * | brson joined #nimrod |
12:42:47 | * | seertaak joined #nimrod |
12:43:41 | milosn | Araq: cool |
12:44:08 | milosn | hmm i must tell you, nimrod is easely cool-est thing ive discovered this year :) |
12:44:15 | milosn | well done :) |
12:55:11 | Araq | thank you |
12:57:26 | seertaak | hi quick question: coming from C++ background, I'm used to seeing constructors/destructors (not least for RAII). Does nimrod support them? |
12:59:41 | seertaak | Ah, I just saw in the manual there are destructors via {.destructor.} pragma. |
13:03:05 | seertaak | However, I'm still not clear on how constructors work -- the nimrod tutorial (II) doesn't seem to mention anything, and the manual also isn't clear |
13:05:33 | * | Varriount|Mobile joined #nimrod |
13:05:51 | * | darkf quit (Quit: Leaving) |
13:06:12 | Varriount|Mobile | seertaak: Nimrod doesn't have constructors, as such |
13:06:23 | * | Jesin quit (Quit: Leaving) |
13:07:25 | Varriount|Mobile | It has procedures that create and setup new instances of objects, like newSeq, initTable, etc |
13:08:39 | Varriount|Mobile | but these are regular procedures |
13:10:14 | Varriount|Mobile | Destructors and finalizers are special because they are called implicitly, sometimes by the garbage collector |
13:11:18 | * | io2 joined #nimrod |
13:12:14 | seertaak | Varriount: ok, thanks for the explanation |
13:19:59 | * | brson quit (Quit: leaving) |
13:23:48 | * | seertaak quit (Ping timeout: 240 seconds) |
13:29:09 | bastian_ | hi |
13:29:22 | dom96 | hi bastian_ |
13:29:46 | bastian_ | i'm currently implementing a parser in C with a push-style API |
13:30:17 | * | BitPuffin quit (Ping timeout: 264 seconds) |
13:30:47 | bastian_ | is it possible to allocate memory for a string on the C side, pass it to nimrod, and have it handle memory (deallocate it at some point) for me? |
13:31:18 | bastian_ | or is it necessary to create a copy? |
13:32:20 | * | BitPuffin joined #nimrod |
13:33:07 | Araq | you need to create a copy or you call 'newObj' from C |
13:34:16 | Araq | I would simply write the parser in nimrod though :P |
13:36:04 | Araq | you can also wrap the string in some 'ref' and attach a finalizer to that |
13:36:14 | bastian_ | already have it working using ragel |
13:36:31 | Araq | ah good point |
13:36:41 | Araq | a ragel backend for nim would be sweet |
13:37:22 | bastian_ | looked at it, but the existing backends seem rather intimidating |
13:41:49 | bastian_ | Araq: could you elaborate on the two non-copy approaches? how would I call newObj from C, and how would wrapping work? |
13:43:08 | Araq | type Foo = ref object |
13:43:14 | Araq | cs: cstring |
13:43:39 | Araq | proc createFoo(x: cstring): Foo = |
13:43:47 | Araq | new(result, finalizer) |
13:43:52 | Araq | result.cs = x |
13:44:18 | Araq | proc finalizer(f: Foo) = free(f.cs) |
13:44:44 | Araq | that's the wrapping approach |
13:46:15 | Araq | proc nimCreateString(size: int): pointer {.exportc.} = |
13:46:30 | Araq | result = cast[pointer](newString(size)) |
13:46:42 | bastian_ | ah, interesting. this looks quite like what i'm looking for |
13:46:57 | bastian_ | thanks! |
13:47:00 | Araq | and then use 'nimCreateString' in C, but you need to know Nimrod's string layout |
13:47:06 | Araq | for this to work |
13:48:08 | bastian_ | cool. think i'll go with wrapping, as with the other approach the parser would be nimrod-specific |
13:48:15 | Araq | it's typedef struct { long Len; long Cap; char data[]; } *NimString; iirc |
13:48:35 | * | Varriount|Mobile quit (Remote host closed the connection) |
13:48:56 | Araq | the parser should be nimrod specific though |
13:49:06 | Araq | how else will we conquer the world? |
13:49:36 | Araq | make people program in nimrod as all the libraries you want to use are in nimrod too. |
13:50:32 | Araq | Look at Objective C's success. It doesn't play well with anybody so people have no choice. |
13:51:37 | bastian_ | heh :) |
13:53:46 | bastian_ | btw: here are my first steps in nimrod: github.com/turbolent/ketu |
13:54:26 | bastian_ | any suggestions for approach / performance / code-style are very welcome |
13:54:33 | bastian_ | esp. k2tree.nim |
14:07:04 | * | Varriount|Mobile joined #nimrod |
14:07:05 | * | Varriount|Mobile quit (Client Quit) |
14:07:45 | * | uvelichitel joined #nimrod |
14:14:10 | milosn | hmm i am trying to do: for k, v in pairs(my_table) |
14:14:14 | milosn | but it dont work :) |
14:14:32 | milosn | whats the correct way to do it, before i google :D |
14:14:43 | milosn | i expected it to work as in python |
14:19:57 | dom96 | are you trying to iterate over keys and values? |
14:20:06 | dom96 | if so then that should work |
14:20:12 | milosn | unpacking works only in let and var |
14:20:16 | milosn | i found it :) |
14:20:37 | milosn | so its: for p in pairs(my_table): |
14:20:44 | milosn | than i unpack in let |
14:22:55 | milosn | dom96: it should? i cant get it to work ... let me try again |
14:23:04 | milosn | maybe i had an error someplace else |
14:23:07 | * | milosn not sure |
14:24:20 | milosn | dom96: indeed it does, i had error someplace else, was not reading what it actually was ... thought my 'for' doesnt work |
14:24:23 | milosn | cool |
14:24:23 | * | io2_ joined #nimrod |
14:25:07 | * | Jesin joined #nimrod |
14:26:25 | * | io2 quit (Ping timeout: 252 seconds) |
14:27:37 | * | menscrem joined #nimrod |
14:28:27 | menscrem | hi all |
14:28:49 | dom96 | hello menscrem |
14:36:13 | * | io2_ is now known as io2 |
14:36:26 | milosn | dom96: you made nimrod? |
14:36:35 | dom96 | milosn: Nope. Araq did. |
14:36:36 | milosn | as in, you started the project |
14:36:39 | milosn | ah |
14:36:49 | milosn | its like python just faster and better |
14:36:50 | milosn | :D |
14:37:15 | * | milosn loves it |
14:38:04 | menscrem | whether there is a ternary operation Nimrod? |
14:38:07 | milosn | dom96: is it possible to make "active record" style ORM (having in mind what nimrod is) ... or even better did someone made it already? |
14:38:08 | dom96 | milosn: That's exactly why I use it. A long time ago I used python. |
14:38:38 | milosn | i havent looked at macros yet, not good at that stuff ... but maybe in nimrod they are easy |
14:38:48 | dom96 | menscrem: You mean the ?: operator? |
14:39:23 | menscrem | Yes |
14:39:36 | * | darithorn joined #nimrod |
14:40:41 | dom96 | milosn: Never used 'active record' so i'm not sure, but I bet it's possible. |
14:41:06 | dom96 | milosn: Play around with templates first, they are simpler than macros and may be enough for your needs. |
14:41:12 | milosn | thats where i had problem with scala, it was just to rigid ... that kinda stuff cant be done easely |
14:41:26 | dom96 | menscrem: No, but you can do this instead: let x = if y: 5 else: 8 |
14:41:53 | milosn | templates? ill have a look ... i am just at basic level at the moment ... getting to know data structures and stuff |
14:42:18 | milosn | so far i wrote ... err 188 lines of nimrod, including empty lines and comments :P |
14:42:28 | milosn | :) |
14:42:59 | dom96 | milosn: I would really love to see an ORM using Nimrod's macros. |
14:43:17 | dom96 | milosn: If you get stuck we can always help :) |
14:43:32 | milosn | we shall see :) |
14:43:48 | milosn | if i get time to play around with, i might give it a go |
14:45:25 | menscrem | dom96: thank you |
14:55:10 | * | Skrylar quit (Ping timeout: 252 seconds) |
15:22:14 | Varriount | bbodi: Concerning your PR. When I use parseurl on many of dom96's examples, the fields of the URL objects are empty, when it seems they shouldn't be. |
15:22:32 | Araq | oh hi Varriount |
15:22:40 | Araq | did you revert whatever you did wrong? |
15:23:06 | Varriount | Yeah. |
15:23:51 | Varriount | Right Click -> Revert Commit -> Push and Open PR -> Accept PR -> Reopen Issue. |
15:28:34 | bbodi | Varriount: Where can I find these examples? |
15:32:35 | * | Skrylar joined #nimrod |
15:56:11 | * | seertaak joined #nimrod |
15:56:58 | * | seertaak quit (Client Quit) |
16:00:00 | * | untitaker quit (Ping timeout: 240 seconds) |
16:04:18 | bbodi | In D, you can do the following "array[pos..$]", where '$' denotes the array size. Is there anything similar construct in Nimrod? If not, dont you find it useful? |
16:05:16 | * | untitaker joined #nimrod |
16:07:11 | Varriount | bbodi: Use echo(repr()) on the url objects in the example dom96 gives in the old PR |
16:08:10 | Varriount | Also, I really feel that we should stick to whatever standard there is on handling URL's. We can implement non-standard behvior as other procedures. |
16:13:53 | EXetoC | milosn: what error message do you get for "for k, v in pairs(my_table)"? unpacking iterator yields should work too |
16:15:22 | dom96 | EXetoC: he got it working |
16:15:34 | Varriount | I think iterator unpacking should follow the same syntax as tuple unpacking in var statements. Otherwise you get ambiguity when iterating over objects like sequences of two-item tuples. |
16:15:54 | dom96 | bbodi: I don't think so, would be nice to have though. |
16:16:22 | renesac | bbodi, you can do arr[pos..arr.high] |
16:17:04 | EXetoC | dom96: Didn't he say that he was unpacking in a variable? I don't know why he has to do that |
16:17:24 | EXetoC | let me re-rerad |
16:17:35 | EXetoC | *re-read |
16:17:36 | renesac | not as compact as D, but '$' is a general operator in nimrod... we don't have many characters left |
16:17:44 | bbodi | it should be then arr[pos..arr.high-1] or arr[pos.. <arr.high], dont? |
16:18:00 | renesac | arr.high = arr.len - 1 |
16:18:07 | EXetoC | ok nevermind |
16:18:12 | bbodi | oh thanks |
16:18:49 | EXetoC | milosn: disregard that |
16:21:14 | EXetoC | renesac: hm, macro to the rescue? |
16:22:30 | EXetoC | but it matters mostly for long names really |
16:22:48 | renesac | and when you do lots of slicing, like in D |
16:22:58 | * | io2 quit () |
16:23:10 | renesac | what macro you were thinking about? |
16:25:58 | Varriount | renesac, bbodi: I've tried to think how one would implement an operator like that, but I think the only way that such a thing could be done is with term rewriting macros, or possibly a regular macro. |
16:26:27 | renesac | on D it is backed into the language |
16:26:34 | EXetoC | the former of which you cannot rely on for semantics |
16:26:37 | renesac | and I don't think '$' is used for something else |
16:30:19 | Araq | with a slight parser/grammar patch we could easily support s[0..$] |
16:30:42 | Araq | but I prefer s[0..] as a syntax |
16:30:53 | Varriount | Araq: That would be fine too. |
16:31:15 | renesac | interesting option |
16:31:18 | Araq | we only need the rule "infix operator before ], }, ) becomes a postfix operator" |
16:31:22 | bbodi | using '$' is not a good idea, I just picked one example from D, we shouldnt follow them, because we use '$' for another thing. The point here is to using some simple, short expression |
16:31:45 | bbodi | I thing too that s[0..] is much better |
16:32:07 | renesac | it remembers me of python, where it is 's[0:]' |
16:32:11 | Araq | but then the language already has a prefix '..' for s[..x] |
16:32:16 | renesac | indeed it is much better |
16:32:22 | EXetoC | x.. is nice |
16:32:32 | Araq | so this would require yet another pragma to disambiguate |
16:32:37 | Varriount | Araq: Tell me again why negative string slicing "s[0.. -1]" is inefficient? |
16:32:58 | Araq | because the hardware doesn't support it natively? |
16:33:06 | Varriount | Huh? |
16:33:59 | Varriount | But it's just the same as s[0..(s.len()-1)-1], isn't it? |
16:34:18 | Araq | no, it is not |
16:34:20 | renesac | Varriount, I think you have a '-1' too much there |
16:34:28 | Araq | check out what the implementation in system.nim does |
16:35:12 | Varriount | renesac: len() returns the number of items in an collection. Indices start at 0 |
16:35:45 | renesac | but 's[-1]' isn't the last item? |
16:36:17 | Varriount | renesac: No, second to last. |
16:36:48 | renesac | in python it means the last one |
16:37:00 | renesac | '-2' is second to last |
16:37:06 | Araq | s[-1] IS the last item, if it would be valid, that is |
16:37:27 | dom96 | IMO it should be valid |
16:38:30 | dom96 | after all, "expressive" is above "efficient" on the website :P |
16:38:47 | renesac | dom96, I think they are together |
16:38:48 | renesac | :P |
16:39:27 | Araq | argh |
16:39:45 | dom96 | The website is wrong it seems "Nimrod's design focuses on efficiency, expressiveness, elegance (in the order of priority)." |
16:39:45 | Araq | it used to be "efficient expressive elegant" in the order of priority |
16:39:56 | Araq | yeah, didn't notice it |
16:40:15 | Varriount | It seems that we are giving Araq a headache. :P |
16:40:32 | renesac | for integer literals, it would be equivalent performance as the compiler could translate between the two forms |
16:40:45 | Araq | -1 is really only meaningful as literal, IMHO |
16:40:51 | Varriount | proc `[]`*(s: string, x: TSlice[int]): string {.inline.} = |
16:40:52 | Varriount | ## slice operation for strings. Negative indexes are supported. |
16:40:52 | Varriount | result = s.substr(x.a-|s, x.b-|s) |
16:40:57 | Araq | let x = parseInt(stdin.readLine) |
16:40:58 | renesac | but when the value isn't known at compile time it would generate more code |
16:41:04 | Araq | echo foo[x] |
16:41:21 | Araq | # do you really want to allow x == -1 here? |
16:41:38 | renesac | Araq, if it had no runtime overhead, yes |
16:41:42 | renesac | :P |
16:41:59 | renesac | of course, you would do some input validation before using untrusted input |
16:42:06 | Varriount | What does the '|s' mean? |
16:42:09 | Araq | that's true |
16:42:21 | Araq | Varriount: -| is an operator |
16:42:36 | Araq | it does "minus plus some bounds check" |
16:42:42 | Araq | it's also defined in system |
16:43:26 | Varriount | So.. I don't see how the hardware limits it. |
16:43:59 | Araq | well as renesac said, it requires an 'if' for every subscript operation |
16:44:35 | Araq | people will shout "this is no systems programming language" on reddit if we do that |
16:45:00 | renesac | well, it can be optimized to a cmov I think, but yeah |
16:45:07 | Varriount | cmov? |
16:45:35 | renesac | an if that does not do branching, it executes the two options in parallel |
16:45:40 | Varriount | Araq: We're already doing a comparison for bounds checking. |
16:45:48 | Araq | Varriount: not in release mode |
16:45:49 | renesac | and picks the correct one latter |
16:47:04 | * | Jesin quit (Quit: Leaving) |
16:47:04 | renesac | or something like that, I'm not that into assembly |
16:47:16 | Varriount | Hm. Ah well. people can do "s[-1..-1] if they really way. |
16:47:19 | Varriount | *want |
16:47:30 | Araq | we can also do something like this: |
16:48:11 | Araq | type Foo = tuple[x: int] |
16:48:54 | Araq | proc `~ `(x: int): Foo = result.x = x |
16:49:28 | renesac | result.1? |
16:49:55 | Araq | proc `[]` [T](a: openArray[T], f: Foo): T = a[a.len - f.x] |
16:50:03 | Araq | echo a[~1] |
16:50:37 | Araq | the type Foo only serves as a disambiguator for overloading resolution |
16:50:49 | renesac | right |
16:50:52 | Varriount | Why not distinct int? |
16:51:44 | Varriount | Or is that a stupid question. |
16:52:08 | Varriount | Araq: Anyway, I give in, you're right. |
16:53:10 | Varriount | I see why it would be inefficient. And I'm hesitant to add an operator procedure to the stdlib for such a common type, since there's only a limited number of operator combination people can remember and use. |
16:53:10 | renesac | another thing I would like is the third field that python and some other languages have |
16:53:17 | Varriount | renesac: Stride? |
16:53:19 | renesac | that describes the step |
16:53:45 | renesac | but in nimrod we only have binary operators |
16:53:51 | Varriount | Personally, I've rarely, if ever, seen the step/stride feature used. |
16:54:12 | Araq | x[::-1] is an idiom for "reverse" in python |
16:54:16 | renesac | well, I used it more just to revert the ... |
16:54:17 | renesac | yeah |
16:54:42 | Varriount | An inefficient idiom. reverse() is much better both memory and performance wise. |
16:55:00 | Varriount | Perhaps stride/step could be implemented as a third argument? |
16:55:29 | Araq | that's just an implementation detail though, Varriount. I bet a JIT for Python optimizes both to the same. |
16:55:46 | renesac | Varriount, why inneficient? |
16:55:51 | Varriount | Araq: For Pypy, yeah. Not CPython :/ |
16:56:04 | renesac | if you know it at compile time, you can replace by a "reverse()" |
16:56:12 | renesac | if you don't, you would need an 'if' anyway |
16:56:54 | renesac | of course, it is a bit inefficient if you just need an positive integer step |
16:57:06 | renesac | that is not known at compile time |
16:57:19 | Araq | renesac: we'll get more efficient slicing soon as they part of my new master plan :P |
16:57:27 | Araq | strides however are not part of it |
16:57:36 | Varriount | renesac: Master plan? Tell all, please. |
16:57:52 | renesac | that was for Araq, right? |
16:57:54 | Varriount | Also, I thought you were working on threading stuff. |
16:58:01 | Varriount | Er, yes. |
16:58:16 | Varriount | Araq: Master plan? Tell all, please. |
16:58:19 | Araq | it's all secret |
16:58:30 | renesac | well, strides need copying, except when in generators |
16:58:39 | renesac | like a counter in a 'for' loop |
16:59:16 | renesac | actually, you could even add an additional field in a slice to say the stride.. |
16:59:57 | renesac | it would be more efficient for applications that need it... but that is rare... |
17:00:01 | Varriount | Hmf. It's ideas like this that need a well though out enhancement proposal document. |
17:01:15 | Araq | Varriount: feel free to introduce the first "Nimrod enhancement proposal" (NEP) |
17:02:43 | Varriount | Araq: Now that you mention it.. |
17:03:19 | renesac | actually, just a nice generator functionality would obliviate the need of such special stride field |
17:03:36 | renesac | if I could pass an generator as if it was a seq |
17:03:44 | renesac | that is what is cool in D ranges |
17:04:59 | renesac | you implement an algorithm for a 'random acess range', or something like that |
17:05:11 | * | bbodi quit () |
17:06:16 | renesac | http://ddili.org/ders/d.en/ranges.html |
17:06:56 | EXetoC | I wanted to do that with UDTCs, but I'm waiting for bug fixes |
17:08:50 | EXetoC | so that it's part of the actual type interface, which allows for overloading and so on |
17:14:47 | EXetoC | but I haven't tested something like "c.isRandomAccess == true" yet |
17:15:44 | EXetoC | or maybe the last part can be chopped off, if it does indeed work at all |
17:16:15 | EXetoC | but then you have a to associate a constant with a type somehow |
17:17:06 | Araq | isRandomAccess = has [] and len, right? |
17:18:01 | EXetoC | that might be good enough |
17:18:14 | Araq | though I always though "isRandomAccess" is a bad joke |
17:18:18 | Araq | *thought |
17:18:45 | Araq | "oh yeah, lets see, what's random access in practice? oh yeah, arrays. anything else? no..." |
17:19:27 | Araq | depending on how you look at it, hardware doesn't know such a thing as "random access" anymore |
17:19:52 | Araq | or finger trees are random access'y enough |
17:21:22 | Varriount | I always though that random access, at it's most basic, meant that arbitrary parts of a piece of information could be accessed and/or read to. |
17:21:58 | EXetoC | I guess if you count abstractions, but the underlying type should still be an array I guess |
17:22:21 | Araq | what the heck means "random access"? why is that a useful generic constraint? is O(lg N) access too slow? maybe but does the algorithm stop working for that then? |
17:22:58 | Araq | I'd call it "arrayLike" instead |
17:26:35 | EXetoC | "RandomAccessFinite RandomAccessInfinite RandomFiniteAssignable..." :-) |
17:29:18 | * | Demos joined #nimrod |
17:31:48 | renesac | Araq, it does not need to be an array, it can be a function |
17:39:07 | Araq | renesac: and yet I'd expect an overloaded [] if it resemembles an array |
17:40:37 | Demos | I think I agree with araq, although something like KeyValueContainer[K,V] may be OK |
18:06:32 | * | Jesin joined #nimrod |
18:21:59 | * | BitPuffin quit (Ping timeout: 252 seconds) |
18:25:31 | Skrylar | does it seem like every rule of math is arbitrarily bolted on to anyone else? |
18:32:46 | Demos | not really, there do seem to be quite a few paths that get you all the rules though |
18:32:53 | Demos | which I guess is good |
18:37:42 | * | bbodi joined #nimrod |
18:38:59 | bbodi | I have the following module hierarchy: a/a.nim, and a/b/b.nim. From b.nim, I want to import a.nim in the following way: import ../a.nim. But I get Error: invalid module name: '../ a' |
18:45:46 | Araq | import "../a" should work |
18:47:20 | bbodi | But it doesnt. You can try it by cloning https://github.com/bbodi/WhiteStag and nimrod c -r WhiteStagEditor\renderer\sdlengine.nim |
18:49:20 | * | BitPuffin joined #nimrod |
19:03:48 | Araq | imported with the "" ? |
19:04:08 | bbodi | oh sorry |
19:04:29 | bbodi | with "" its ok |
19:07:03 | OrionPK | hola |
19:10:17 | * | menscrem quit (Quit: Page closed) |
19:34:22 | * | springbok joined #nimrod |
19:34:24 | Demos | if you are compileing from the parent directory you import a/a.nim |
19:34:29 | Demos | oh or that |
19:41:44 | * | bbodi quit (Ping timeout: 252 seconds) |
20:00:27 | * | Demos quit (Read error: Connection reset by peer) |
20:08:00 | EXetoC | fowl: does verlet.nim compile for you? |
20:08:09 | EXetoC | "sdl2/engine2.nim(4, 16) Error: cannot open 'fowltek(/|/|/)sdl2" |
20:09:53 | EXetoC | module/directory collision? |
20:11:51 | fowl | sdl2/engine2 still refers to fowltek/sdl2 >_> |
20:11:57 | * | njoejoe joined #nimrod |
20:14:01 | Araq | hi springbok welcome |
20:14:30 | njoejoe | is there something like: str = ['data',123,variable].join(",") in nimrod? |
20:14:46 | Araq | yes. it's called "join" |
20:14:51 | Araq | and should be in the index |
20:15:22 | njoejoe | thank you. i need to remember the index... |
20:15:43 | springbok | Thanks Araq. Curious about Nimrod. Looking around. |
20:21:12 | EXetoC | fowl: is it suitable for player movements? |
20:21:52 | EXetoC | box2d isn't for example. I couldn't be bothered with the hacks that need to be applied |
20:27:56 | * | nande joined #nimrod |
20:31:24 | EXetoC | I guess not |
20:43:14 | fowl | EXetoC, are you doing a platformer |
20:43:35 | EXetoC | I'm not doing anything |
20:44:02 | * | [2]Endy quit (Read error: Operation timed out) |
20:44:06 | fowl | oh |
20:44:18 | EXetoC | but I usually have top-down mechanics in mind |
20:45:02 | fowl | chipmunk or box2d should work for that |
20:45:12 | * | shevy joined #nimrod |
20:45:24 | fowl | assuming you mean top-down as in asteroids |
20:45:54 | EXetoC | yep |
20:49:29 | * | Skrylar quit (Ping timeout: 264 seconds) |
20:53:31 | njoejoe | how to do something like this in a loop?: var1,var2,var3 = line.split(",") |
20:55:07 | uvelichitel | Hi there. Can't quite understand what for 'method' are. Please point me some code base using them to read |
20:56:56 | EXetoC | uvelichitel: polymorphism (virtual in C++ [vtable]) |
20:57:23 | * | Skrylar joined #nimrod |
21:01:00 | Araq | njoejoe: there is a macro for that somewhere |
21:01:42 | EXetoC | does it involve a temporary? |
21:01:56 | * | Matthias247 quit (Read error: Connection reset by peer) |
21:02:20 | Araq | who cares |
21:02:45 | Araq | who uses "split" when efficiency is important anyway :P |
21:03:18 | uvelichitel | EXetoC: C++ have inheritance, Haskell type-classes and Go interfaces to exploit methods polymorphism. Can't clear understand Nimrod approach. Please show the code |
21:06:12 | uvelichitel | EXetoC: I mean real code base, not example in manual. Thanks |
21:08:32 | fowl | uvelichitel, this project makes extensive use of methods: https://github.com/bbodi/WhiteStag |
21:09:08 | uvelichitel | fowl: Thanks. Let me see |
21:09:30 | EXetoC | polymorphism implies inheritance I think |
21:09:35 | EXetoC | runtime polymorphism at least |
21:10:37 | renesac | nimrod also has many compile time mechanisms, like our type-classes |
21:11:13 | renesac | and very good generic programming in general |
21:13:13 | uvelichitel | renesac: Don't take me wrong. Nimrod is nice. Question was exactly about multy-methods |
21:14:11 | renesac | right, I was just pointing out the other alternatives |
21:14:24 | * | renesac never used multi-methods in nimrod |
21:14:25 | njoejoe | Araq: I wonder if this is it: https://gist.github.com/gradha/8140318 i just tried it, and it seems it works with "let (var1,var2)..." but haven't gotten it to work without the "let" keyword. |
21:14:53 | renesac | njoejoe, there is a feature request for this in the issue tracker |
21:14:54 | renesac | :P |
21:15:30 | renesac | you need to use a temporary tuple and then unpack it one field at time |
21:15:58 | renesac | if you want to reuse previous variables |
21:25:41 | * | brihat joined #nimrod |
21:26:06 | Araq | njoejoe: yeah that's what I had in mind |
21:43:36 | * | uvelichitel quit (Quit: Textual IRC Client: www.textualapp.com) |
21:51:00 | njoejoe | i think this would be awesome: (var1:int,var2:string,var3:float) = line.split(",") but i don't think it can be done with a macro. can it be done with whatever mechanism that #!strongSpaces uses? where could I read up on that? |
21:51:49 | Araq | #!strongSpaces is totally different |
21:52:06 | Araq | but what you want could be done with a macro |
21:54:48 | njoejoe | that's good news. i will read up on them now. |
21:56:54 | njoejoe | nimrod is a yak shavers delight :-) |
21:57:22 | * | uvelichitel joined #nimrod |
22:00:01 | dom96 | and here I thought you people were actually shaving yaks |
22:09:47 | * | Jesin quit (Quit: Leaving) |
22:11:00 | * | Varriount|Mobile joined #nimrod |
22:12:50 | Varriount|Mobile | Araq: How hard would it be to change the compiler's parsing code to support parenthesized groups of identifiers for variable unpacking in for loops? |
22:13:28 | Varriount|Mobile | The current unparenthesized situation is ambiguous. |
22:14:11 | EXetoC | why is it? |
22:15:07 | dom96 | for k, i in blah: # could mean unpacking or k is value and i is index. |
22:15:31 | Varriount|Mobile | EXetoC: Try unpacking when iterating over a sequence of two-item tuples. |
22:16:28 | Varriount|Mobile | Plus, having/forcing parenthesis makes things consistant with tuple unpacking in var statements. |
22:16:47 | Araq | yeah well, iirc we fixed the ambiguity |
22:16:54 | * | Demos joined #nimrod |
22:16:58 | Varriount|Mobile | How? |
22:20:07 | Varriount|Mobile | Araq: How |
22:20:52 | Araq | can't remember |
22:21:04 | Araq | for k, v in x # always calls 'pairs' |
22:21:10 | Araq | can't be used for unpacking |
22:21:14 | Araq | iirc |
22:21:51 | Varriount|Mobile | Yeah, which is unknown, and still ambiguous when read. |
22:22:03 | Varriount|Mobile | *relatively unknown |
22:23:36 | Demos | oh damn, I have been calling pairs explicitly |
22:24:08 | renesac | it is the most common usage |
22:24:36 | renesac | and consistent with the tuple unpacking syntax, it seems |
22:24:54 | renesac | do 'for (k,v) in x' do tuple unpacking? |
22:25:01 | Araq | Varriount|Mobile: implicit tuple unpacking in 'for' is awful for generic code |
22:25:25 | Araq | but yeah, we could support 'for (a, b, c) ' for tuple unpacking |
22:25:28 | Varriount|Mobile | renesac: I'm not disagreeing with using pairs, I'm just suggestion that parenthesizing tuple unpacking in iterators be made allowable/mandatory |
22:25:49 | Varriount|Mobile | Araq: Why is it terrible? |
22:39:30 | dom96 | I agree with Varriount|Mobile, we should support it. |
22:41:59 | * | Skrylar quit (Ping timeout: 255 seconds) |
23:08:59 | * | darkf joined #nimrod |
23:18:24 | * | Jesin joined #nimrod |
23:38:16 | njoejoe | is there a way to have string interpolation of variables in scope? "hello #{p.name}, you are #{p.age} years old" is so handy |
23:39:28 | * | brson joined #nimrod |
23:40:21 | * | uvelichitel quit (Quit: Textual IRC Client: www.textualapp.com) |
23:47:27 | Varriount | njoejoe: I think that there may be a macro somewhere in the tests that does that. If nothing else, it's doable with a macro. |
23:49:32 | * | brson quit (Quit: leaving) |
23:50:02 | njoejoe | it's all coming up macros! hopefully macros can use other macros because i want to use this in a macro :-) |
23:55:36 | Varriount | njoejoe: To put it bluntly, although I see the merit of that kind of macro, it's not high up on the priorities of any of the developers, and noone has submitted a PR for it. |
23:56:02 | * | Varriount is currently porting python stuff to nimrod |