00:33:32 | * | Endeg quit (*.net *.split) |
00:33:32 | * | XAMPP quit (*.net *.split) |
00:33:36 | * | OrionPK quit (*.net *.split) |
00:33:39 | * | comex quit (*.net *.split) |
00:33:42 | * | dom96 quit (*.net *.split) |
00:44:45 | * | Trixar_za is now known as Trix[a]r_za |
00:52:46 | * | OnionPK joined #nimrod |
00:52:46 | * | Endeg joined #nimrod |
00:52:46 | * | XAMPP joined #nimrod |
00:52:46 | * | comex joined #nimrod |
00:52:46 | * | dom96 joined #nimrod |
00:52:48 | * | Trix[a]r_za is now known as Trixar_za |
01:53:09 | * | q66 quit (Remote host closed the connection) |
01:59:26 | * | Nimrod joined #nimrod |
02:01:11 | * | Trixar_za is now known as Trix[a]r_za |
02:02:13 | * | Nimrod_ quit (Ping timeout: 248 seconds) |
02:07:12 | * | Trix[a]r_za is now known as Trixar_za |
03:00:42 | * | reactormonk joined #nimrod |
03:00:47 | reactormonk | sup |
03:01:45 | reactormonk | Araq, any way to stop both gcc and linker call and replace that with my own exec, just one per project? |
03:01:54 | reactormonk | Nimrod, down in texas too? ;-) |
03:32:52 | * | Trixar_za is now known as Trix[a]r_za |
03:57:24 | reactormonk | hmm, c2nim can't parse function pointers |
03:57:26 | reactormonk | void attachInterrupt(uint8_t, void (*)(void), int mode); |
03:57:38 | fowl | yeah |
03:57:50 | fowl | just pull that out into a typedef right above the function |
04:02:32 | * | OnionPK quit (Read error: Connection reset by peer) |
04:14:33 | * | Endeg quit (Read error: Connection reset by peer) |
04:29:06 | Nimrod | [22:01:58] <reactormonk> Nimrod, down in texas too? ;-) |
04:29:18 | Nimrod | Nope, back from Texas (where I go to school) |
04:52:55 | reactormonk | Nimrod, aww |
04:53:03 | reactormonk | fowl, hum? |
04:53:51 | reactormonk | Nimrod, where? |
04:54:02 | Nimrod | What? |
04:54:20 | * | Nimrod left #nimrod ("Leaving") |
04:54:25 | reactormonk | NimBot, which school. |
05:03:52 | fowl | reactormonk: c2nim has problems with complex types inside func decls like that |
05:04:10 | fowl | so just pull the void(*)(void) into a typedef and use that in the function |
05:06:06 | reactormonk | looks like a function to me |
05:06:14 | reactormonk | so a `proc` annotation should do |
05:06:29 | reactormonk | also, the file has a shitload of macros |
05:07:48 | fowl | yea |
05:08:21 | fowl | i'd just put typedef void (*foo)(void); above it then change foo to something sensible later |
05:08:40 | fowl | macros are annoying, they've made me give up on more than a few wrappers |
05:19:29 | * | fowl quit (Ping timeout: 256 seconds) |
05:31:53 | * | fowl joined #nimrod |
05:53:20 | reactormonk | would be nice to have all of them |
05:54:34 | reactormonk | hmm |
05:54:42 | reactormonk | fowl, how would you define the above? |
05:56:04 | fowl | typedef void (*callback)(void); |
05:58:04 | fowl | or typedef void *callback(void); |
06:02:32 | reactormonk | huh? |
06:02:39 | fowl | what |
06:02:40 | reactormonk | or just `proc` in nimrod? |
06:02:41 | fowl | what are you asking me |
06:02:46 | fowl | oh |
06:03:01 | fowl | void attachInterrupt(uint8_t, void (*)(void), int mode); |
06:03:37 | fowl | proc attachInterrupt* (x: uint8, cb: proc(): pointer, mode: cint) {.importc.} |
06:04:29 | fowl | that proc(): pointer should probably be {.cdecl.} too |
06:04:53 | fowl | or at least {.noconv.} |
06:10:26 | reactormonk | noconv? |
06:13:25 | reactormonk | extern const uint16_t PROGMEM port_to_mode_PGM[]; |
06:13:30 | reactormonk | how do I deal with that? |
06:13:53 | fowl | what des PROGMEM do |
06:14:50 | reactormonk | http://pastie.org/private/3dhwbkblf13m8phxvz53ig |
06:21:57 | fowl | var port_to_mode* {.importc, nodecl.}: ptr cushort |
06:22:31 | fowl | unless PROGMEM does something .. |
06:26:38 | reactormonk | those are registers |
06:29:46 | fowl | dunno what that means |
06:31:00 | reactormonk | hardware registers |
06:31:02 | reactormonk | at least volatile |
06:31:35 | fowl | i dont think that register/volatile belongs between the type and name, it should be more to the left by extern |
06:34:24 | reactormonk | what's extern? |
06:35:28 | fowl | http://publications.gbdirect.co.uk/c_book/chapter8/const_and_volatile.html |
06:38:37 | fowl | reactormonk: i think it has something to do with whats exposed in the DLL |
06:39:17 | reactormonk | the target is ARM |
06:42:32 | reactormonk | yep, I have read that one before |
06:47:21 | reactormonk | fowl, forgot about PROGMEM |
07:07:09 | * | ARCADIVS quit (Quit: WeeChat 0.3.8) |
08:24:47 | * | Endeg joined #nimrod |
09:53:35 | * | q66 joined #nimrod |
11:42:16 | * | fowl quit (Ping timeout: 256 seconds) |
11:45:31 | * | zahary_ joined #nimrod |
14:51:43 | * | Endy joined #nimrod |
15:09:53 | * | Endy quit (Ping timeout: 248 seconds) |
16:08:37 | * | Trix[a]r_za quit (Ping timeout: 248 seconds) |
16:11:30 | * | Trix[a]r_za joined #nimrod |
16:21:38 | reactormonk | the nasty part about this is - I need macros here, as it looks like |
16:26:45 | reactormonk | what does typedef void PROGMEM prog_void; |
16:26:46 | reactormonk | mean? |
16:26:59 | reactormonk | #define PROGMEM __ATTR_PROGMEM__ |
16:27:11 | reactormonk | #ifndef __ATTR_PROGMEM__ |
16:27:14 | reactormonk | #define __ATTR_PROGMEM__ __attribute__((__progmem__)) |
16:27:16 | reactormonk | #endif |
16:48:38 | Araq | reactormonk: {.pragma becreative, extern: "PROGMEM $1".} |
16:48:52 | Araq | var x {.becreative.}: int |
17:12:36 | reactormonk | interesting. |
17:16:44 | * | Endy joined #nimrod |
17:19:57 | reactormonk | hm. |
17:23:34 | Araq | ping zahary_ |
17:28:52 | * | fowl joined #nimrod |
17:29:57 | reactormonk | extern const uint8_t PROGMEM digital_pin_to_timer_PGM[]; => const array[uint8] digital_pin_to_timer_PGM {.becreative, importc:"digital_ping_to_Timer_PGM".} ? |
17:30:14 | Araq | C's const is not Nimrod's const |
17:30:25 | Araq | why do you think c2nim ignores it? |
17:30:37 | reactormonk | true again |
17:32:58 | fowl | reactormonk: did my line not work |
17:33:17 | Araq | var digital_pin_to_timer_PGM {.importc: "PROGMEM digital_pin_to_timer_PGM".}: ptr array [0..2000, byte] |
17:33:26 | Araq | and yeah I made up the 0..2000 |
17:40:57 | * | ARCADIVS joined #nimrod |
17:43:07 | * | Endy quit (Ping timeout: 264 seconds) |
17:52:54 | * | q66_ joined #nimrod |
17:54:19 | reactormonk | fowl, the ptr part? |
17:54:54 | fowl | what sorry |
17:55:20 | * | q66 quit (Disconnected by services) |
17:55:25 | * | q66_ is now known as q66 |
18:04:48 | * | Endy joined #nimrod |
18:53:02 | reactormonk | Araq, any way to address it without the []? |
18:53:12 | reactormonk | I think it's pointer arithmetics here |
18:53:39 | Araq | that's why I made it an array for ya |
18:53:50 | Araq | so you can use it as myvar[23] |
18:54:00 | reactormonk | hm |
18:54:07 | reactormonk | and I gotta figure out the bounds myself. |
18:54:16 | Araq | not really |
18:54:26 | Araq | just come up with some absurd upper limit |
18:54:42 | Araq | you won't have any reasonable bounds checking then |
18:54:47 | reactormonk | ok |
18:54:56 | Araq | but then you can't get that easily if you don't know the size |
18:55:18 | Araq | and if the C API exposes only such a crappy interface there is only so much you can do about it |
18:55:41 | reactormonk | kk |
19:29:09 | * | Endy quit (Ping timeout: 248 seconds) |
19:46:49 | reactormonk | Araq, yeah, that's the hardware interface, depending on the board |
20:03:04 | Araq | guys, I have news: |
20:03:47 | Araq | I'll make a speech at the next emerging langs |
20:04:16 | Araq | on Wed Sept 18th |
20:05:14 | Araq | in my humility I named the talk: "Nimrod: A new approach to meta programming" :-) |
20:06:07 | reactormonk | :D |
20:07:17 | dom96 | Awesome. I hope they record it! |
20:07:33 | Araq | I allowed recording :P |
20:07:33 | reactormonk | Araq, where is that one? |
20:07:49 | Araq | St. Louis, Missouri |
20:08:21 | dom96 | oh cool, they replied to my tweet: https://twitter.com/d0m96/status/335469190196625409 |
20:08:29 | dom96 | "Not sure yet" :\ |
20:08:48 | Araq | well I can release the video I think |
20:08:59 | dom96 | I would fly there if it wasn't so damn expensive to fly to the USA. |
20:09:15 | reactormonk | Araq, when not(defined(Arduino_h)): <- a little bit too near the original |
20:09:17 | dom96 | Araq: Yeah, but they also have to record it. |
20:09:40 | Araq | reactormonk: I tweak the C input until the generated code fits |
20:09:57 | Araq | in other words I'd remove the #ifdef crap in the header file |
20:11:11 | reactormonk | http://sprunge.us/TZce O.o |
20:11:32 | Araq | reactormonk: just remove it |
20:11:42 | Araq | nimrod supports binary numbers via 0b000111 |
20:11:49 | reactormonk | figured so ;-) |
20:12:26 | reactormonk | template constrain*(amt, low, high: expr): expr = |
20:12:29 | reactormonk | (if (amt) < (low): (low) else: (if (amt) > (high): (high) else: (amt))) |
20:12:31 | reactormonk | do we have something for that? |
20:12:47 | Araq | yeah system.clamp |
20:12:53 | dom96 | Araq: You should get a twitter account and live tweet about the whole conference ;) |
20:13:04 | Araq | over my dead body :P |
20:13:56 | dom96 | But what if someone makes dongle jokes behind you? How will you punish those fools if not with a twitter account? |
20:14:13 | reactormonk | Araq, we can do that |
20:14:49 | Araq | "punish"? I'd congratulate them |
20:15:18 | dom96 | You will still need twitter for that :P |
20:16:06 | dom96 | Araq: Do a live tweet pretty pleaseee |
20:16:37 | Araq | I'm live in #nimrod instead |
20:17:00 | Araq | and tell you guys how my bowel is working |
20:17:29 | dom96 | ok, but you must take pictures, upload them somewhere and give us links :P |
20:17:45 | Araq | meh, pics of my bowel ... I dunno ... |
20:18:14 | dom96 | no! The conference man, the conference! |
20:20:47 | Araq | meh I'll make some pics that maybe happen to have something to do with the conference (*cough* girls *cough*) |
20:21:13 | dom96 | yeah, good luck finding any :P |
20:46:32 | fowl | Araq: of course you would do a talk in STL after I leave. -_- |
20:47:55 | fowl | oh its in september, i might be back there then |
20:49:47 | Araq | good |
20:51:51 | reactormonk | Araq, #define interrupts() sei() |
20:52:01 | reactormonk | produces template noInterrupts*(: expr): expr = cli() |
20:52:30 | Araq | how so? |
20:52:40 | reactormonk | template interrupts*(): expr = sei() |
20:53:00 | Araq | looks like a good translation |
20:53:35 | reactormonk | wait, I corrected it |
20:53:38 | reactormonk | template interrupts*(: expr): expr = sei() |
20:53:56 | Araq | that looks weird :P |
21:03:14 | reactormonk | Araq, I assume converting them from template to proc is fine |
21:05:18 | Araq | depends on the template but yeah |
21:05:32 | reactormonk | proc clockCyclesToMicroseconds*(a: int): int = |
21:05:35 | reactormonk | ((a) div clockCyclesPerMicrosecond()) |
21:05:51 | reactormonk | what about http://sprunge.us/VeiJ ? |
21:08:44 | Araq | looks quite good |
21:08:55 | Araq | c2nim is quote smart :P |
21:08:58 | Araq | *quite |
21:09:48 | reactormonk | not sure what the types here are |
21:10:03 | reactormonk | all ints? |
21:10:16 | Araq | why not leave it as templates and 'expr'? |
21:12:04 | reactormonk | type |
21:12:07 | reactormonk | boolean* = uint8_t |
21:12:09 | reactormonk | byte* = uint8_t |
21:12:11 | reactormonk | hm |
21:12:19 | fowl | those are bs |
21:12:34 | fowl | you can just use bool |
21:13:08 | reactormonk | http://sprunge.us/PjeV <- what about those? |
21:13:09 | Araq | and system.byte |
21:13:16 | reactormonk | I suppose I don't need the first three |
21:13:46 | fowl | you have to translate those avr/ files or just the relevant datatypes/functions |
21:14:23 | fowl | scratch the part of the sentence about relevant data/types functions, im high >_> |
21:15:31 | reactormonk | no nice little 'paste c include statement here'? |
21:15:57 | Araq | sorry; no. |
21:17:25 | reactormonk | so I gotta convert the whole tree? |
21:17:57 | Araq | perhaps |
21:18:14 | fowl | reactormonk: i just do the minimum that it takes to get a demo working then finish it later |
21:19:00 | Araq | reactormonk: C headers often contain mostly bullshit like typedefs to work around C's broken primitive types etc. etc. |
21:19:39 | fowl | have you run into any unions yet |
21:19:47 | reactormonk | now the little problem is this: #include "pins_arduino.h" |
21:19:55 | reactormonk | aaand http://sprunge.us/EhYF |
21:20:39 | Araq | looks like they went the "lets use the FS instead of the PP" route ... |
21:20:56 | Araq | resulting in even "cleaner" code |
21:21:02 | Araq | for your wrapping pleasures |
21:21:11 | fowl | they should have a common API |
21:21:28 | Araq | true, good point, fowl |
21:21:42 | reactormonk | PP? |
21:21:52 | Araq | preprocessor |
21:22:04 | reactormonk | oh |
21:22:24 | reactormonk | http://sprunge.us/WUIB it's not that much |
21:23:34 | reactormonk | so, how do I work with this? |
21:25:40 | reactormonk | translate every single file? |
21:27:33 | Araq | translate the file for your board? |
21:28:56 | reactormonk | hm |
21:33:00 | reactormonk | http://sprunge.us/XaaV oh god... |
21:36:05 | fowl | reactormonk: does it not translate? |
21:36:22 | reactormonk | nope |
21:36:33 | fowl | just make it ptr array[0 .. <5, cushort] |
21:36:44 | fowl | oh is that for your board |
21:36:47 | reactormonk | yep |
21:39:09 | fowl | var port_to_mode_PGM*{.importc.}: ptr array[0.. <1024, uint16] |
21:39:57 | fowl | reactormonk: dont translate the file and your board specific stuff, just find the common api |
21:40:17 | reactormonk | fowl, yeah, that's why I asked for the pin include |
21:40:28 | reactormonk | I have the common API here |
21:40:41 | reactormonk | or just a good old #include macro statement |
21:41:02 | reactormonk | but that would be PITA to translate as soon as nimrod gets its own compiler backend |
21:41:58 | fowl | reactormonk: all the declaring is just so that nimrod knows how to get to the func/var and how to treat it (the type) |
21:42:15 | reactormonk | Yeah. But how do I tell nimrod to import X? |
21:42:59 | fowl | you dont, you have a pins_arduino.nim that lays out the common structure of those system-specific files |
21:44:26 | fowl | unsized arrays are always ptr array[0..int.max, T] |
21:47:50 | fowl | that is because they point to a DATA section or an allocated pointer #someone correct me if im wrong |
21:49:08 | Araq | I prefer array [0.. 100_000, T] instead of int.max; this way you get at least somewhat meaningful checking |
21:49:31 | Araq | you don't want to access the whole address space with it anyway |
21:59:32 | fowl | how i prevent s from copying on line 4 https://gist.github.com/fowlmouth/704acc4b0e78ae18192f |
22:01:30 | Araq | use local variables and use shallowCopy instead of '=' |
22:01:36 | Araq | in 'foo' |
22:01:47 | reactormonk | http://sprunge.us/ONha |
22:01:49 | reactormonk | hm |
22:02:00 | reactormonk | the problem is that they use different types depending where the stuff is |
22:02:06 | reactormonk | ... multiple address spaces. |
22:03:36 | Araq | no need for the 'var string' then either fowl |
22:03:54 | reactormonk | actually it's typedef void prog_void PROGMEM; |
22:04:00 | reactormonk | the other is just doxygen WA |
22:08:40 | Araq | I don't get it; standard C would be volatile void* that points to some fixed address |
22:11:01 | Araq | in fact ... I'd use inline assembler for the poke/peek primitives and then use those. it's already as CPU specific as it can get. C doesn't help here |
22:21:39 | * | OrionPK joined #nimrod |
22:22:02 | fowl | Araq: why is there no isEmpty() or something like that for seqs |
22:22:06 | fowl | /strings |
22:23:27 | Araq | I use s.len == 0 |
22:24:10 | Araq | I'm not too happy with lots of aliases for trivial things |
22:24:23 | fowl | i dont think its trivial |
22:24:42 | fowl | whether i need .len > 0 or .len == 0, they are checking the same thing |
22:25:50 | fowl | and its really common >_> |
22:26:49 | OrionPK | how about .isThereAnythingInHere?() |
22:29:00 | Araq | what if your string only consists of whitespace? :P |
22:29:32 | OrionPK | C# has IsNullOrWhiteSpace() :) |
22:32:11 | Araq | C# also has string.Empty |
22:32:26 | Araq | very useful, otherwise you'd have to use "" |
22:32:52 | OrionPK | yeah, although "" probably uses string.Empty at runtime |
22:35:04 | * | zahary_ quit (Ping timeout: 256 seconds) |
22:35:05 | Araq | fowl: what's not trivial about .len > 0? |
22:35:37 | Araq | I get 'not isNil' vs 'isNil' wrong just as I get '== 0' vs > 0 wrong |
22:37:03 | Araq | in fact it's a common bug for me, doesn't matter how it's named ('empty' / 'full') |
22:43:14 | fowl | its irritating to write all the time when the concept is "is this empty" |
22:43:52 | fowl | time for a new module fowltek/libfowl |
22:44:11 | Araq | import rubyness ? |
22:45:09 | Araq | import pythonness --> converter toBool(s: string): bool = s.len != 0 |
22:45:20 | fowl | yes i'll have `template unless*(cond; body:stmt):stmt = if not cond: body` in there too |
22:45:22 | Araq | if "yay": echo "woo hoo" |
22:46:22 | fowl | python prefers explicit to implicit and "" is true |
22:46:38 | Araq | python doesn't make any sense |
22:46:47 | Araq | how is dynamic typing explicit? |
22:47:19 | Araq | that's not some small feature ... the language is dynamic like crazy |
22:47:57 | fowl | i guess thats why its called a dynamic language? |
22:48:27 | Araq | yeah but the "explicit over implicit" rule is some major bullshit then |
22:48:29 | fowl | explicit to implicit in things like the global keyword, explicit return statement, declaring self as a method parameter |
22:48:56 | fowl | i asked in #python and they told me the language is designed for n00bs |
22:49:01 | Araq | sorry these are all minor things compared to lack of any type annotations |
22:52:11 | fowl | well in relevance to your converter example, theres no implicit between bool and anything, only False and None are false, the rest are objects and represent truth, i dont think that has a place in nimrod and i try to only use converters conservatively |
22:53:25 | Araq | huh? |
22:53:35 | Araq | if "abc": # valid python |
22:54:14 | Araq | python has a notion of emptiness that does convert to bool |
22:54:23 | Araq | well in 'if' and the like |
22:54:35 | fowl | bool("") |
22:54:38 | fowl | #=> False |
22:54:49 | fowl | if "": print("hi") |
22:54:54 | fowl | # nothing |
22:55:10 | Araq | yep |
22:55:41 | Araq | so it's not just False and None that are false |
22:55:42 | fowl | (bool(0), True if 0 else False) |
22:56:12 | fowl | #> (False, False) |
22:56:47 | fowl | eh i read it wrong |
22:59:06 | fowl | anyways im only suggesting isEmpty() for strings/collections |
23:01:40 | Araq | yeah. I'm against it. |
23:01:47 | Araq | except perhaps in this form: |
23:01:56 | Araq | template isEmpty(x: expr): bool = x.len == 0 |
23:02:16 | Araq | so that any collection that has a 'len' has it automatically |
23:02:34 | Araq | I don't want to re-implement trivial stuff for each collection type |
23:05:34 | fowl | word |