Recent content by Aniki

  1. Aniki

    Sorty loops 2

    Relaxed the comparison from '<=>' to just '<', i.e instead of this if xs[sortIdxA] < xs[sortIdxB] then set cmp = -1 elseif xs[sortIdxB] < xs[sortIdxA] set cmp = 1 else set cmp = 0 endif it's now just: set lt = xs[sortIdxA] < xs[sortIdxB] Added a similar interface for binary...
  2. Aniki

    PJass updates

    It seems the game thinks that (tested on version 1.31): returning nothing is false (probably because of the implicit return 0 in the bytecode) returning integer 1 is true, 0 is false returning real 1.0 is true, 0.0 is false returning boolean true is true, false is false :^) returning string ""...
  3. Aniki

    PJass updates

    @LeP The 'code' type is rather strange. One can assign to a variable of type 'code' a function that returns anything (any type) and nothing (void type). pjass doesn't seem to complain (ignoring the '+filter' flag and the ('Filter', 'Condition') natives) and the game is probably fine with this...
  4. Aniki

    PJass updates

    shameless plug... @Prometheus3375 Although it's unlikely that you will get better error messages from JiffyJass' check mode than pjass, you could try, maybe? There's a script attached to this post that you can use to convert your 'common.j' to something that can be used by JiffyJass for the...
  5. Aniki

    Annoying quirk with lua '#' length operator: finding first non-nil value in a straight array

    I think in Lua when you set a table/map's key to 'nil' it's equivalent to removing that key-value pair (similarly to JavaScript's "delete map[key]"). The manual's entry about the '#' operator (the length operator) explains how it relates to nil values in a table (returning a random "border"). If...
  6. Aniki

    Sorty loops 2

    An algorithmic improvement from insertion sort to shellsort: globals integer array sortgaps integer sortstate integer sortn integer sortgap integer sorta integer sortb integer sortc integer sortcmp integer sortIdxA integer sortIdxB endglobals // must be...
  7. Aniki

    FourCC breaks in V1.31

    It seems that after a load (at least on v1.31) 'string.unpack' becomes an alias for 'table.unpack', and 'string.pack' becomes an alias for 'table.pack'. If this is true then this seems like a typo kind of error to me. local function callMeAfterLoad() -- after a load 'string.unpack' becomes...
  8. Aniki

    Sorty loops 2

    This is a follow up of Sorty loops which is "Not open for further replies". I don't know why I didn't think of this earlier but it's very easy to go one step further and make the user do the swapping themselves. This way we avoid the copying from the user's arrays to ours. It also simplifies...
  9. Aniki

    FourCC breaks in V1.31

    This is almost as bizarre as that bug that prevented save games from loading after writing to index 8191 of an array in older patches... save/loading is hard, I guess. Here's a "goofy" way to stick to 'string.unpack' but not fail after a load: local strUnpack = string.unpack local function...
  10. Aniki

    FourCC breaks in V1.31

    Looking in 'lua-src/lstrlib.c/str_pack,str_unpack', I am not seeing anything related to multi-byte encoding. Strings in Lua are "Lua is 8-bit clean: strings can contain any 8-bit value, including embedded zeros ('\0'). Lua is also encoding-agnostic; it makes no assumptions about the contents of...
  11. Aniki

    FourCC breaks in V1.31

    If 'GetFourCC' uses 'string.pack', why not use 'string.unpack' for 'FourCC'? It's what blizzard's version does: -- Helper function that enables the following syntax: ARCHMAGE = FourCC('Hamg') function FourCC(id) return string.unpack(">I4", id) end Anyway... 'GetFourCC' seems like a bad...
  12. Aniki

    Jass Hot Code Reload

    Yeah, it works now with common.j-1.26. Have you tried this (not very modern though)? Hm... the order of evaluation is different. Well... actually it isn't =). I'll be trying 'or' expressions next (to see if there are any bugs lurking there =)). Edit: 'or' expressions seem fine (although they...
  13. Aniki

    Jass Hot Code Reload

    Tried with the 'jhcr-1.29.zip' and common.j (1.26, 1.29 and 1.31) but in-game (running 1.31) it I am getting an error (when the map gets selected). Previously I was using 'jhcr-126b-128.zip' (v. git-c50f36) with common.j-1.26 (again running 1.31). I still think the bytecode generated by the...
  14. Aniki

    Jass Hot Code Reload

    It seems that 'jhcr' generates incorrect bytecode for 'and' expressions, it also generates pretty good bytecode for nested if statements, and that's a bit ironic =): function B1 takes nothing returns boolean call BJDebugMsg("B1()") return false endfunction function B2 takes nothing...
  15. Aniki

    Jass Hot Code Reload

    Yeah, it shouldn't be as dramatic because hashtable functions in wc3 are natives. ¯\_(ツ)_/¯ I was looking (despite not having a clue about Haskell) in 'Jass/Opt/Rewrite/SomeRules.hs' and the stuff there seemed like a very terse way of doing tree rewriting. But then I tried (jhcr compile...
Top