« first day (1 day earlier)      last day (1534 days later) » 

2:38 AM
@ngn bitbucket username jibanes
 
 
4 hours later…
ngn
6:09 AM
@JeromeIbanes done. glad to see you in this chat
 
6:57 AM
@ngn Bitbucket username is "chrispsn" - thank you!
 
 
3 hours later…
9:47 AM
@ngn could you make it not exit on error?
 
 
3 hours later…
ngn
12:25 PM
@chrispsn done, and thanks for posting at r/apljk
@JeromeIbanes that's kind of hard :( let me explain. most of my c functions are designed to "consume" their unreffed args (i.e. args that have refcount=0). "consume" means do one of the following: free the memory, or refcount++ the object (e.g. by putting it in some list), or reuse and return the same object (modifying its content in-place and possibly changing its type), or pass the object on to another arg-consuming function
the obvious way to handle errors is to return NULL and have the caller check for NULL and do the same. but if this happens in the middle of a function i must first free the memory of any not-yet-freed args, which seems to be a lot of work and very hard to test
 
ngn
12:53 PM
exit()-ing on error wasn't much of a problem so far. i write my k code in vim and i have a shortcut to run the current file through the interpreter - always starting from scratch. but if this is to go beyond golfing, indeed i need to be able to handle errors gracefully
 
@ngn have you used something like github.com/StanfordPL/stoke to optimise the binary?
 
ngn
@chrispsn no, just clang and its options
@chrispsn "Status of this Work [...] We're not quite at the point where we can take a generic loop and expect to improve gcc/llvm -O3 code"
 
 
1 hour later…
2:09 PM
@ngn what's the print function in your k? getting some segfaults and want to see what's causing it
ah wait got it (just 1)
 
@ngn give me read access I'll send you the patches
 
2:27 PM
any advice on how to handle the segfaults arising from some char combinations in this? tio.run/…
 
2:37 PM
Suppose running a separate process for each generated program could work shrug
 
 
2 hours later…
ngn
4:31 PM
@chrispsn 1@"string" writes to stdout. 0N!value prints the value formatted as k code and returns the value. i might remove or change these to adapt to more recent versions of k, if and when information about them becomes available
 
ngn
4:53 PM
@JeromeIbanes i'd rather be the only one hacking at the language core, but i'll think about a sample verb impl to post here for the sake of discussion. i'll have to explain it - my code would probably be unreadable even if you are accustomed to whitney c, as i use different macros and different abbreviations from what i've seen documented in k's c api
@chrispsn c: "!@#$%^&*.<>,/?'\|" - backslash is an escape character, so it should be doubled up
perms: ! len {(#c),x}/() - i wouldn't call this permutations. there's a simpler way to do it:
c@!len##c
 
ngn
5:09 PM
@chrispsn so, @/1 2 3 4 segfaults indeed. i will investigate. thanks. fuzzing is good :)
 
ngn
5:34 PM
ok, found it. whether 1@2 should do anything at all or throw a type error like in k4 is a different matter
oK and kona don't allow that either
 
 
2 hours later…
7:17 PM
@ngn no problem, thanks for making the binary available at any rate
@ngn yeah would be interested to see a verb code
 
ngn
@JeromeIbanes this is reverse (unary |):
v1(rev){
 $(xn<2||xt>=tf,R x)
 $(xt==th,x=mut01(x);xx=mi(rev(xx));xy=mi(rev(mo(xy)));R x)
 $(xt==tg,x=mut10(x);xy=mi(eac(cu_rev,&xy,1));R x)
 A z=ax(x);$(!xt&&x!=z,miAll(x))
 L j=xn,m=(xn+1)/2;
 Y(tz(xt),en,
  Q(1,fi(m,--j;C v=xci;zci=xcj;zcj=v))
  Q(8,fi(m,--j;L v=xli;zli=xlj;zlj=v)))
 R z;}
there's a lot i have to explain, it might take a while...
v1 means a unary verb
#define v1(f) A f(A x)
A is just an aligned V* (i.e. void*), i use it for "arrays" (k objects)
like in arthur's code $ is if and R is return
xn and xt are macros for accessing the length and type of x
there are similar macros xa, xc, xl, and xd for accessing the content of the array as an A*, C* (i.e. char*), L* (i.e. long long* - i don't use arthur's J), and D* (i.e. double* - i don't use F)
xx and xy mean xa[0] and xa[1] - the first and second items of a generic list
type contants:
tc tl ts td th tg tf tp tq tr tu tv tw
"" !0 ``     h +h {} 1+ ++ +/ +: +  /
td is the type of 0.1 2.3; th is the type of a dict; tg - table (a flipped dict)
tC tL tS tD are the corresponding scalar types to tc tl ts td
xli means xl[i] and similarly for {xyzu} × {acld} × {ij}
Y(expr,default,cases...) is switch. Q(value,body) is case...break
mi(x) and mo(x) are refcount++ and refcount-- (i think arthur uses ci(x) and cd(x) for these)
@JeromeIbanes makes sense so far?
 
7:44 PM
are there tables in K, or only in q?
 
ngn
@ktye i'm not very familiar with the "db" side of k, but if i understand correctly, a "table" is just a flipped dictionary, which is present in (at least) k4
 
i havn't seen in the ok doc.
What about key-tables. The apter-table paper linked above, speaks about the q universe where they play a role.
I wonder what makes them so special that it justifies a special type.
 
ngn
@ktye i don't know what a key-table is
i would guess just a normal table with "attributes" or something to give the interpreter hints for how to optimise lookups. but i could be wrong
 
"keytables are dictionaries which map tables to tables". But they are special in that each row maps to each row, as far as I understand. In q they are printed specially. I just don't know, why this is needed and not just all in one table...
 
 
2 hours later…
9:47 PM
@ngn thanks, yeah, it makes sense.
 
ngn
@JeromeIbanes ok, a few more things: dicts and tables are 2-element lists internally - (keys;values). mut01(x) and mut10(x) create a mutable copy of a 2-element list x, reusing it if possible. 01 unrefs the first element and keeps the second element reffed. 10 does the opposite. kind of ugly, but i was able to shave off some milliseconds with this.
ax(x) creates a new object with the same type and length as x, reusing x if possible
 
nice!
do you support read0 etc?
 
ngn
eac is each. initially i implemented adverbs as if they are 3-arg verbs, but then switched to this calling convention: adverb(A operand, A*args, L nArgs)
@JeromeIbanes yeah, but it's very limited right now. golfing doesn't require much i/o
0: and 1: work. their unary versions (read) use mmap(). the binary versions (write) use write() which is a shame...
they work only for regular files. no sockets and more advanced stuff
by the way, 2: (the verb for dealing with dynamic libraries) is essential if ngn/k is gonna be used in the real world. i tried to implement it but got bogged down in the details of the elf format and how it's supposed to get loaded in memory
 

« first day (1 day earlier)      last day (1534 days later) »