00:19:16 | * | q66 quit (Quit: Quit) |
01:12:58 | * | XAMPP quit (Quit: Leaving) |
01:44:25 | * | XAMPP joined #nimrod |
07:07:59 | fowl | zahary: / Araq : perhaps in CPP mode `let` should declare things as const... :) |
08:12:03 | * | zahary quit (Read error: Operation timed out) |
08:15:39 | * | zahary joined #nimrod |
08:17:38 | * | zahary quit (Read error: Connection reset by peer) |
08:37:50 | * | zahary joined #nimrod |
12:40:03 | * | shevy quit (Quit: "") |
14:10:06 | * | q66 joined #nimrod |
15:13:34 | * | FreeArtMan joined #nimrod |
15:14:01 | FreeArtMan | hi |
15:42:02 | FreeArtMan | is there possible to compile shared library? |
15:59:08 | dom96 | hello FreeArtMan |
15:59:23 | FreeArtMan | hey0 |
15:59:38 | dom96 | You mean create a DLL? |
16:02:17 | FreeArtMan | i mean SO =] |
16:02:26 | FreeArtMan | but in Win its DLL |
16:02:32 | dom96 | mm yeah |
16:03:40 | dom96 | http://build.nimrod-code.org/docs/nimrodc.html#dll-generation |
16:17:11 | FreeArtMan | is there smaller example? |
16:23:20 | dom96 | not sure, maybe when Araq gets here he can give you one. |
16:23:31 | FreeArtMan | ok |
16:23:45 | FreeArtMan | i will try to find somethin |
16:27:08 | FreeArtMan | found --app:lib |
16:28:32 | FreeArtMan | it gives name of function like function__XXXXXX |
16:31:48 | FreeArtMan | is there possible to give function such name that when it compiled it has normal C name |
16:31:54 | FreeArtMan | i mean in object file |
16:36:41 | dom96 | use the exportc pragma |
16:36:51 | dom96 | {.exportc: "name".} |
16:50:39 | FreeArtMan | wohoo. it works |
16:50:46 | FreeArtMan | thx dom96 |
16:50:59 | FreeArtMan | will try now write some so |
16:59:58 | dom96 | FreeArtMan: cool :D |
17:37:39 | FreeArtMan | nimrod string is same as C string? |
17:38:33 | dom96 | no. |
17:38:52 | dom96 | cstring is the same |
17:39:04 | FreeArtMan | is there conversion function? |
17:41:20 | dom96 | I think you can just do: cstring(stringHere) |
17:48:05 | dom96 | although nimrod strings are implicitly converted to cstring's |
17:48:39 | dom96 | http://build.nimrod-code.org/docs/manual.html#cstring-type |
17:51:16 | * | XAMPP quit (Ping timeout: 244 seconds) |
17:52:31 | * | XAMPP joined #nimrod |
17:52:31 | * | XAMPP quit (Changing host) |
17:52:31 | * | XAMPP joined #nimrod |
18:03:26 | FreeArtMan | why nimrod dont allow tab =[ |
18:08:07 | dom96 | Because spaces are better :P |
18:11:34 | FreeArtMan | need make my own nimrod fork =D with tabs!!! |
18:14:13 | Araq | FreeArtMan: yes; either that or you could learn how to use a real editor ... :P |
18:14:33 | FreeArtMan | never! |
18:14:34 | FreeArtMan | =D |
18:15:50 | FreeArtMan | is **char == array char? |
18:17:12 | Araq | char** is cstringArray most of the time |
18:18:08 | FreeArtMan | char* cstring? |
18:22:47 | Araq | yes |
18:29:00 | FreeArtMan | how can be define in nimrod struct _x { void (*xchat_free) (xchat_plugin *ph, void *ptr);}; |
18:29:18 | FreeArtMan | struct thats is type |
18:30:16 | Araq | struct is 'object' or 'tuple' |
18:30:32 | Araq | and you could try c2nim to translate the types for you |
18:30:49 | FreeArtMan | ok |
18:31:28 | FreeArtMan | in SDL wrapper i see something like Timer* = proc (interval: int32): int32{.cdecl.} |
18:31:40 | FreeArtMan | but will try c2nim now |
18:32:35 | FreeArtMan | c2nim gives me error =D |
18:41:48 | FreeArtMan | it becouse of int f(int(*callback)(char *)) |
18:41:59 | FreeArtMan | call back can be simply as proc then? |
18:46:04 | Araq | yeah but pick the right calling convention |
18:46:53 | Araq | proc f(callback: proc (x: cstring): cint {.cdecl.}): cint |
19:28:01 | dom96 | Araq: Seems you broke my code. |
19:29:00 | dom96 | Araq: {.push: cdecl.} is now {.push cdecl.} |
19:33:32 | Araq | well ... {.push: cdecl.} never did work correctly |
19:33:44 | Araq | so it's nice you get an error for it now :P |
19:40:55 | dom96 | really? |
19:43:44 | Araq | yes |
19:44:52 | dom96 | Araq: How did it not work properly? |
19:48:12 | dom96 | I'm kind of tempted to run RISC OS on my Pi and try Nimrod on it :P |
19:50:12 | Araq | dom96: risc os, hu? interesting |
19:50:25 | dom96 | yeah |
19:50:38 | Araq | it did not work properly because it ignored the pragma after the colon |
19:51:59 | dom96 | I see |
20:11:51 | Araq | fowl: you can push 'exportc' now btw |
20:15:26 | * | gradha joined #nimrod |
20:15:27 | FreeArtMan | i have strange type that compiles on c but not on nimrod |
20:16:30 | FreeArtMan | typedef struct _xchat_plugin xchat_plugin; |
20:16:49 | FreeArtMan | and struct _xchat_plugin{} defined after this statment |
20:17:13 | FreeArtMan | and nimrod tells that its not defined |
20:19:27 | dom96 | how are you defining it in Nimrod? |
20:20:41 | Araq | FreeArtMan: use this: |
20:20:44 | Araq | type |
20:20:53 | Araq | TXchatPlugin = object |
20:21:08 | FreeArtMan | i can show it in c |
20:21:15 | FreeArtMan | typedef struct _str str; |
20:21:15 | FreeArtMan | struct _str |
20:21:15 | FreeArtMan | { |
20:21:15 | FreeArtMan | int i; |
20:21:15 | FreeArtMan | }; |
20:21:44 | Araq | type |
20:21:53 | Araq | TStr = object |
20:21:57 | Araq | i: cint |
20:23:11 | FreeArtMan | but if there is also typedef struct _str str; without struct _str? |
20:24:06 | Araq | it's hard to explain but it means you can either write 'struct _str' or 'str' |
20:24:26 | Araq | the 'typedef' defines an alias for 'struct _str' |
20:24:42 | FreeArtMan | even if struct never defined somewhere |
20:24:50 | Araq | if you only have an alias and no 'struct' declaration it's an anon struct type |
20:25:03 | FreeArtMan | type |
20:25:05 | Araq | which means you don't tell the compiler about its fields |
20:25:13 | FreeArtMan | ok |
20:25:15 | Araq | and can only use pointers to it |
20:25:21 | FreeArtMan | and how i can make it? |
20:25:28 | FreeArtMan | anon struct |
20:25:34 | FreeArtMan | ^type |
20:25:57 | Araq | an empty struct type can be done like this: |
20:26:07 | Araq | type X = object |
20:39:00 | FreeArtMan | uh |
20:39:08 | FreeArtMan | almost everything fixed now |
20:39:41 | FreeArtMan | Error: implementation of '' expected |
20:40:02 | FreeArtMan | what if it is only interface nothing more? |
21:04:35 | * | FreeArtMan quit (Read error: Operation timed out) |
21:19:26 | gradha | while implementing a new db_sqlite.getRow I've discovered that none of the currently available procs will return nil values from the database |
21:19:43 | Araq | oh really? |
21:19:54 | Araq | ever occured to you it's a feature? :P |
21:20:13 | gradha | well, db people surely won't be happy about that |
21:20:44 | Araq | I've enough db experience to count as a "db" guy :P |
21:21:23 | gradha | how fortunate that your experience is the only true one |
21:21:54 | Araq | well if it's useful to me it may be useful to somebody else ;-) |
21:22:33 | Araq | "may be useful for the guys that can only talk" is not as much fun ;-) |
21:22:48 | Araq | we need an 'isNull' proc though |
21:22:57 | gradha | I've implemented a new getRow supporting nils, but if you want to I'll make it discard them as empty strings |
21:24:36 | Araq | yeah please |
21:24:57 | Araq | hopefully we'll get rid of 'nil' as a valid value for strings anyway |
21:25:25 | gradha | how would you support nil values, like python's None object? |
21:25:52 | Araq | people love a "maybe" type these days |
21:26:03 | gradha | are they coders? |
21:26:14 | Araq | I prefer API duplication most of the time |
21:26:46 | Araq | getenv --> returns "" for non-existing keys; existsEnv if you really need to differentiate |
21:27:10 | Araq | dunno if ever used existsEnv ... |
21:27:54 | gradha | this "maybe" type sounds wonderful, tell me more about it, do they implement it with rand()? |
21:28:16 | dom96 | say that in #haskell and you're golden. :P |
21:29:31 | gradha | well, for a moment http://java2k.blogspot.com.es/p/java2k.html crossed my mind when reading a "maybe" type |
21:30:25 | Araq | I don't get what you mean with 'rand()' |
21:30:39 | Araq | in nimrod it would like: |
21:30:49 | Araq | type TMaybe[T] = object |
21:30:52 | gradha | rand(), as in C function, returning a random value |
21:30:57 | dom96 | A Maybe type is just a prettier (to some, I guess) way of doing proc getValue(value: var string): bool |
21:30:59 | Araq | case hasValue*: bool |
21:31:12 | Araq | of true: value*: T |
21:31:17 | Araq | of false: nil |
21:31:41 | Araq | except that nimrod doesn't make you check 'hasValue' for every access of 'value' |
21:32:11 | Araq | but it does a runtime check for you |
21:32:42 | dom96 | I think a Maybe type could be good if it composes well. |
21:33:47 | Araq | a Maybe type is nice but having decent defaults is nicer :P |
21:34:22 | gradha | so in a way, a maybe type simplifies writing procs which would return two values, one for success state, another for the true value |
21:35:51 | Araq | yes |
21:36:03 | dom96 | yes. An Either also exists in the Functional world. |
21:36:50 | Araq | in practice this so common: let x = if y.hasValue: y.value else: "" |
21:36:58 | Araq | that I prefer it as the default |
21:37:14 | gradha | meh, accepting empty string as default value for db |
21:41:45 | Araq | you could wrap the db handle in an object and then add a callback to this object that specifies what to do with nulls ... |
21:42:09 | Araq | so the client can chose between "", nil and an exception |
21:42:17 | Araq | but I think it's overkill |
21:43:49 | Araq | I consider the db_ modules as not as important as I prefer a macro based ORM instead |
21:44:26 | Araq | the lack of type safety when dealing with raw SQL is not very appealing |
21:45:16 | Araq | it's however often incredibly useful too; you can try queries in the db's UI and paste them into your code |
21:46:01 | gradha | I've seen code in nimrod doing inc x, is it something better than doing x = x + 1 or similar? I see inc calls succ... sounds like a lot is going on for incrementing values |
21:47:12 | Araq | I was too used to them from pascal ;-) |
21:47:43 | Araq | 'inc' also existed before += |
21:56:56 | gradha | are there specific unit tests for db_* modules or just what is at the end with isMainModule? |
21:57:32 | Araq | the later |
21:58:00 | dom96 | Well here is a little thing I cooked up to show off Maybe: https://gist.github.com/4137476 |
21:59:44 | dom96 | It's certainly a very FP concept |
22:00:26 | Araq | useValue doesn't return anything ... :P |
22:00:31 | gradha | indeed, still can't make sense from it |
22:01:15 | dom96 | Araq: Yeah, well that's not the point anyway. |
22:01:33 | Araq | what? |
22:01:38 | Araq | you chain it 3 times ... |
22:01:46 | dom96 | The point is the macro changes the TMaybe[string] into a string for you |
22:02:09 | dom96 | and if it can't, it goes into the else branch |
22:02:18 | Araq | that's sweet |
22:02:34 | Araq | you know what I want in the else branch? |
22:02:50 | dom96 | no? |
22:02:52 | Araq | treat it as "" :P |
22:02:56 | gradha | hehe |
22:03:29 | Araq | but ok, it's really sweet |
22:03:52 | dom96 | fromMaybe("", value) |
22:03:53 | dom96 | :P |
22:05:00 | * | Araq is chaning his mind ... |
22:05:04 | Araq | *changing |
22:05:41 | Araq | the nice thing is we can make 'fromMaybe' an operator |
22:06:04 | dom96 | yes. |
22:06:08 | Araq | and specialize it for string |
22:06:44 | dom96 | And you can provide cool operators which let you apply functions to the Maybe values :P |
22:06:51 | dom96 | i.e. <$> |
22:07:00 | dom96 | Just need that nice closure syntax... :P |
22:08:14 | Araq | now the only problem is left that we already have 'nil' for strings and Maybe[string] is slower and uses more space |
22:24:18 | gradha | ok, have this for nitpicking https://github.com/gradha/Nimrod/commit/ca4bebd31012c118f626e1b70704cd154abe3c9d |
22:24:38 | gradha | If you like it I'll replicate to the other db_* modules |
22:26:03 | gradha | but after seeing how nothing returns nil I don't see even myself using it, so maybe the proc should get scrapped and only remain the additional doc notes |
22:26:51 | Araq | gradha: why does it return 2 and not simply the number of results? |
22:27:11 | gradha | wouldn't that have to run through all results available? |
22:27:26 | Araq | dunno, would it? |
22:27:45 | Araq | can't remember the low level details of these APIs |
22:27:46 | gradha | it's the only way I know of calculating remainder rows, other than executing an additional query |
22:28:44 | gradha | as suspected, not very practical to know http://www.mail-archive.com/[email protected]/msg36112.html |
22:29:36 | dom96 | is it the same for all SQL dbs? |
22:29:44 | Araq | alright but then I fail to see the point for checking further only to return the 2 |
22:30:34 | gradha | you can build upon it like with tryinsertid, to raise an exception |
22:31:06 | gradha | and that's why it its pretty useless at all, never heard of anybody checking such things anyway |
22:31:39 | Araq | maybe your idea to return 'bool' instead is better |
22:32:40 | Araq | also I wouldn't do 'row = newRow(L)' |
22:32:59 | Araq | that misses the point of re-using the memory that 'row' should provide |
22:33:20 | gradha | so the proc fails if the user doesn't init it? |
22:33:28 | Araq | make the caller init 'row', yes |
22:35:07 | dom96 | It's probably a good idea as well to let the user know how to init 'row' in that case. |
22:36:05 | gradha | and adds problems if you initialise to the incorrect number of columns, pffft, what a shame of proc |
22:36:17 | gradha | just ignore this |
22:36:33 | Araq | yeah otherwise the people that don't know what they are doin' have to use the other getRow ... what a shame :P |
22:39:50 | dom96 | does seem like an annoyance to readjust the number of columns yourself. |
22:40:20 | Araq | *sigh* you should know your query ... |
22:40:39 | Araq | executing random queries is simply a bad idea |
22:41:19 | Araq | and you should list the fields you really want and not use * so that you can add columns without breaking your code |
22:44:59 | * | gradha quit (Quit: gradha) |
23:05:28 | fowl | freeartman is doing xchat plugin? |
23:05:33 | fowl | i was just working on that last night :D |
23:05:59 | Araq | nice |
23:16:16 | * | shevy joined #nimrod |
23:27:26 | * | shevy quit (Read error: Connection reset by peer) |