<<23-11-2012>>

00:19:16*q66 quit (Quit: Quit)
01:12:58*XAMPP quit (Quit: Leaving)
01:44:25*XAMPP joined #nimrod
07:07:59fowlzahary: / 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:01FreeArtManhi
15:42:02FreeArtManis there possible to compile shared library?
15:59:08dom96hello FreeArtMan
15:59:23FreeArtManhey0
15:59:38dom96You mean create a DLL?
16:02:17FreeArtMani mean SO =]
16:02:26FreeArtManbut in Win its DLL
16:02:32dom96mm yeah
16:03:40dom96http://build.nimrod-code.org/docs/nimrodc.html#dll-generation
16:17:11FreeArtManis there smaller example?
16:23:20dom96not sure, maybe when Araq gets here he can give you one.
16:23:31FreeArtManok
16:23:45FreeArtMani will try to find somethin
16:27:08FreeArtManfound --app:lib
16:28:32FreeArtManit gives name of function like function__XXXXXX
16:31:48FreeArtManis there possible to give function such name that when it compiled it has normal C name
16:31:54FreeArtMani mean in object file
16:36:41dom96use the exportc pragma
16:36:51dom96{.exportc: "name".}
16:50:39FreeArtManwohoo. it works
16:50:46FreeArtManthx dom96
16:50:59FreeArtManwill try now write some so
16:59:58dom96FreeArtMan: cool :D
17:37:39FreeArtMannimrod string is same as C string?
17:38:33dom96no.
17:38:52dom96cstring is the same
17:39:04FreeArtManis there conversion function?
17:41:20dom96I think you can just do: cstring(stringHere)
17:48:05dom96although nimrod strings are implicitly converted to cstring's
17:48:39dom96http://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:26FreeArtManwhy nimrod dont allow tab =[
18:08:07dom96Because spaces are better :P
18:11:34FreeArtManneed make my own nimrod fork =D with tabs!!!
18:14:13AraqFreeArtMan: yes; either that or you could learn how to use a real editor ... :P
18:14:33FreeArtMannever!
18:14:34FreeArtMan=D
18:15:50FreeArtManis **char == array char?
18:17:12Araqchar** is cstringArray most of the time
18:18:08FreeArtManchar* cstring?
18:22:47Araqyes
18:29:00FreeArtManhow can be define in nimrod struct _x { void (*xchat_free) (xchat_plugin *ph, void *ptr);};
18:29:18FreeArtManstruct thats is type
18:30:16Araqstruct is 'object' or 'tuple'
18:30:32Araqand you could try c2nim to translate the types for you
18:30:49FreeArtManok
18:31:28FreeArtManin SDL wrapper i see something like Timer* = proc (interval: int32): int32{.cdecl.}
18:31:40FreeArtManbut will try c2nim now
18:32:35FreeArtManc2nim gives me error =D
18:41:48FreeArtManit becouse of int f(int(*callback)(char *))
18:41:59FreeArtMancall back can be simply as proc then?
18:46:04Araqyeah but pick the right calling convention
18:46:53Araqproc f(callback: proc (x: cstring): cint {.cdecl.}): cint
19:28:01dom96Araq: Seems you broke my code.
19:29:00dom96Araq: {.push: cdecl.} is now {.push cdecl.}
19:33:32Araqwell ... {.push: cdecl.} never did work correctly
19:33:44Araqso it's nice you get an error for it now :P
19:40:55dom96really?
19:43:44Araqyes
19:44:52dom96Araq: How did it not work properly?
19:48:12dom96I'm kind of tempted to run RISC OS on my Pi and try Nimrod on it :P
19:50:12Araqdom96: risc os, hu? interesting
19:50:25dom96yeah
19:50:38Araqit did not work properly because it ignored the pragma after the colon
19:51:59dom96I see
20:11:51Araqfowl: you can push 'exportc' now btw
20:15:26*gradha joined #nimrod
20:15:27FreeArtMani have strange type that compiles on c but not on nimrod
20:16:30FreeArtMantypedef struct _xchat_plugin xchat_plugin;
20:16:49FreeArtManand struct _xchat_plugin{} defined after this statment
20:17:13FreeArtManand nimrod tells that its not defined
20:19:27dom96how are you defining it in Nimrod?
20:20:41AraqFreeArtMan: use this:
20:20:44Araqtype
20:20:53Araq TXchatPlugin = object
20:21:08FreeArtMani can show it in c
20:21:15FreeArtMantypedef struct _str str;
20:21:15FreeArtManstruct _str
20:21:15FreeArtMan{
20:21:15FreeArtMan int i;
20:21:15FreeArtMan};
20:21:44Araqtype
20:21:53Araq TStr = object
20:21:57Araq i: cint
20:23:11FreeArtManbut if there is also typedef struct _str str; without struct _str?
20:24:06Araqit's hard to explain but it means you can either write 'struct _str' or 'str'
20:24:26Araqthe 'typedef' defines an alias for 'struct _str'
20:24:42FreeArtManeven if struct never defined somewhere
20:24:50Araqif you only have an alias and no 'struct' declaration it's an anon struct type
20:25:03FreeArtMantype
20:25:05Araqwhich means you don't tell the compiler about its fields
20:25:13FreeArtMan ok
20:25:15Araqand can only use pointers to it
20:25:21FreeArtManand how i can make it?
20:25:28FreeArtMananon struct
20:25:34FreeArtMan^type
20:25:57Araqan empty struct type can be done like this:
20:26:07Araqtype X = object
20:39:00FreeArtManuh
20:39:08FreeArtManalmost everything fixed now
20:39:41FreeArtManError: implementation of '' expected
20:40:02FreeArtManwhat if it is only interface nothing more?
21:04:35*FreeArtMan quit (Read error: Operation timed out)
21:19:26gradhawhile 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:43Araqoh really?
21:19:54Araqever occured to you it's a feature? :P
21:20:13gradhawell, db people surely won't be happy about that
21:20:44AraqI've enough db experience to count as a "db" guy :P
21:21:23gradhahow fortunate that your experience is the only true one
21:21:54Araqwell if it's useful to me it may be useful to somebody else ;-)
21:22:33Araq"may be useful for the guys that can only talk" is not as much fun ;-)
21:22:48Araqwe need an 'isNull' proc though
21:22:57gradhaI've implemented a new getRow supporting nils, but if you want to I'll make it discard them as empty strings
21:24:36Araqyeah please
21:24:57Araqhopefully we'll get rid of 'nil' as a valid value for strings anyway
21:25:25gradhahow would you support nil values, like python's None object?
21:25:52Araqpeople love a "maybe" type these days
21:26:03gradhaare they coders?
21:26:14AraqI prefer API duplication most of the time
21:26:46Araqgetenv --> returns "" for non-existing keys; existsEnv if you really need to differentiate
21:27:10Araqdunno if ever used existsEnv ...
21:27:54gradhathis "maybe" type sounds wonderful, tell me more about it, do they implement it with rand()?
21:28:16dom96say that in #haskell and you're golden. :P
21:29:31gradhawell, for a moment http://java2k.blogspot.com.es/p/java2k.html crossed my mind when reading a "maybe" type
21:30:25AraqI don't get what you mean with 'rand()'
21:30:39Araqin nimrod it would like:
21:30:49Araqtype TMaybe[T] = object
21:30:52gradharand(), as in C function, returning a random value
21:30:57dom96A Maybe type is just a prettier (to some, I guess) way of doing proc getValue(value: var string): bool
21:30:59Araq case hasValue*: bool
21:31:12Araq of true: value*: T
21:31:17Araq of false: nil
21:31:41Araqexcept that nimrod doesn't make you check 'hasValue' for every access of 'value'
21:32:11Araqbut it does a runtime check for you
21:32:42dom96I think a Maybe type could be good if it composes well.
21:33:47Araqa Maybe type is nice but having decent defaults is nicer :P
21:34:22gradhaso 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:51Araqyes
21:36:03dom96yes. An Either also exists in the Functional world.
21:36:50Araqin practice this so common: let x = if y.hasValue: y.value else: ""
21:36:58Araqthat I prefer it as the default
21:37:14gradhameh, accepting empty string as default value for db
21:41:45Araqyou 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:09Araqso the client can chose between "", nil and an exception
21:42:17Araqbut I think it's overkill
21:43:49AraqI consider the db_ modules as not as important as I prefer a macro based ORM instead
21:44:26Araqthe lack of type safety when dealing with raw SQL is not very appealing
21:45:16Araqit's however often incredibly useful too; you can try queries in the db's UI and paste them into your code
21:46:01gradhaI'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:12AraqI was too used to them from pascal ;-)
21:47:43Araq'inc' also existed before +=
21:56:56gradhaare there specific unit tests for db_* modules or just what is at the end with isMainModule?
21:57:32Araqthe later
21:58:00dom96Well here is a little thing I cooked up to show off Maybe: https://gist.github.com/4137476
21:59:44dom96It's certainly a very FP concept
22:00:26AraquseValue doesn't return anything ... :P
22:00:31gradhaindeed, still can't make sense from it
22:01:15dom96Araq: Yeah, well that's not the point anyway.
22:01:33Araqwhat?
22:01:38Araqyou chain it 3 times ...
22:01:46dom96The point is the macro changes the TMaybe[string] into a string for you
22:02:09dom96and if it can't, it goes into the else branch
22:02:18Araqthat's sweet
22:02:34Araqyou know what I want in the else branch?
22:02:50dom96no?
22:02:52Araqtreat it as "" :P
22:02:56gradhahehe
22:03:29Araqbut ok, it's really sweet
22:03:52dom96fromMaybe("", value)
22:03:53dom96:P
22:05:00*Araq is chaning his mind ...
22:05:04Araq*changing
22:05:41Araqthe nice thing is we can make 'fromMaybe' an operator
22:06:04dom96yes.
22:06:08Araqand specialize it for string
22:06:44dom96And you can provide cool operators which let you apply functions to the Maybe values :P
22:06:51dom96i.e. <$>
22:07:00dom96Just need that nice closure syntax... :P
22:08:14Araqnow the only problem is left that we already have 'nil' for strings and Maybe[string] is slower and uses more space
22:24:18gradhaok, have this for nitpicking https://github.com/gradha/Nimrod/commit/ca4bebd31012c118f626e1b70704cd154abe3c9d
22:24:38gradhaIf you like it I'll replicate to the other db_* modules
22:26:03gradhabut 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:51Araqgradha: why does it return 2 and not simply the number of results?
22:27:11gradhawouldn't that have to run through all results available?
22:27:26Araqdunno, would it?
22:27:45Araqcan't remember the low level details of these APIs
22:27:46gradhait's the only way I know of calculating remainder rows, other than executing an additional query
22:28:44gradhaas suspected, not very practical to know http://www.mail-archive.com/[email protected]/msg36112.html
22:29:36dom96is it the same for all SQL dbs?
22:29:44Araqalright but then I fail to see the point for checking further only to return the 2
22:30:34gradhayou can build upon it like with tryinsertid, to raise an exception
22:31:06gradhaand that's why it its pretty useless at all, never heard of anybody checking such things anyway
22:31:39Araqmaybe your idea to return 'bool' instead is better
22:32:40Araqalso I wouldn't do 'row = newRow(L)'
22:32:59Araqthat misses the point of re-using the memory that 'row' should provide
22:33:20gradhaso the proc fails if the user doesn't init it?
22:33:28Araqmake the caller init 'row', yes
22:35:07dom96It's probably a good idea as well to let the user know how to init 'row' in that case.
22:36:05gradhaand adds problems if you initialise to the incorrect number of columns, pffft, what a shame of proc
22:36:17gradhajust ignore this
22:36:33Araqyeah otherwise the people that don't know what they are doin' have to use the other getRow ... what a shame :P
22:39:50dom96does seem like an annoyance to readjust the number of columns yourself.
22:40:20Araq*sigh* you should know your query ...
22:40:39Araqexecuting random queries is simply a bad idea
22:41:19Araqand 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:28fowlfreeartman is doing xchat plugin?
23:05:33fowli was just working on that last night :D
23:05:59Araqnice
23:16:16*shevy joined #nimrod
23:27:26*shevy quit (Read error: Connection reset by peer)