Mark Sibly

Forum Replies Created

Viewing 15 posts - 1,246 through 1,260 (of 1,431 total)
  • Author
    Posts
  • in reply to: Local scope lambdas #2806

    Mark Sibly
    Keymaster

    Forgot to also mention, you cannot modify ‘captured’ variables inside a lambda, ie: this should give an error:

     

    A lambda effectively gets a ‘copy’ of outer locals at the time the lambda is evaluated. So this..

    …will print ‘0’.

    in reply to: Some help with a mojox GUI #2768

    Mark Sibly
    Keymaster

    Mark, have you thought about a page system and designer?

    I think it’s a great idea, but probably a bit much for me to take on right now.

    in reply to: Static properties? #2767

    Mark Sibly
    Keymaster

    Nope.

    in reply to: Local scope lambdas #2766

    Mark Sibly
    Keymaster

    You need to declare ‘str’ before the lamba, not after.

    in reply to: Structs and the GC #2688

    Mark Sibly
    Keymaster

    Strings are allocated from the heap, but are reference counted instead of GC’d.

    in reply to: Structs and the GC #2675

    Mark Sibly
    Keymaster

    I don’t know how they work under the hood but I think of structs as primitive types.

    This is probably the best way to think of them, and they do in fact work very much like primitive types under the hood, eg:

    Here, both t1 and t2 will both take 4-ish bytes of stack memory (the size of the ‘int’ struct might end up being aligned) and both will ‘disappear’ when the statement block ends (so using Varptr with either is dangerous!).

    Both are also ‘copied’ when assigned to variables or passed to or returned from functions.

    Where things get perhaps a little confusing is with…

    Since MyInt is a struct not a class, the ‘new MyInt’ bit doesn’t actually allocate ‘heap’ memory – it creates a new temporary MyInt (on the stack) that is then copied to t3. Which is actually quite similar to what this does…

    This also creates a temporary int to store the result of 5+10 in (ie: 5+10 is a ‘new Int’), which is then copied to t4.

    But really, apart from this wrinkle there’s nothing really that magical about structs – it’s pointers that are the tricky ones!

    (Note also that when I say ‘on the stack’, this really just means logically on the stack. Compilers generally try to store as much as possible in cpu registers (which are really another form of stack storage) and this applies to structs as much as ints etc. So code like “Local t3:=New MyInt” may well reduce down to a single move instruction to a cpu register).

    Structs and primitives also act the same way when it comes to arrays:

    Both of these will allocate about 400 bytes of heap memory (all arrays are stored on the heap regardless of whether the elements are primitives, structs or classes).

    And in both cases, Varptr a[i+1]-Varptr a[i] will be 4, ie: the values are stored consecutively in memory.

    So structs and primitive types are actually very very similar concepts.

    As for…

    This should in fact be causing a compile time error – something along the lines of ‘struct field initializers must be constant’ (another related story…) – if not, there’s a bug or you’re not using the latest version of mx2cc.

    in reply to: Application exit code #2664

    Mark Sibly
    Keymaster

    Just use libc.exit_( whatever ) directly.

    in reply to: Some help with a mojox GUI #2663

    Mark Sibly
    Keymaster

    I had a quick look through but I don’t I’ll be able to use any of the mojox stuff.

    The problem is (as far as I can tell anyway) too much of it is hard coded in. For example, buttonx uses literal rects/colors etc everywhere.

    On of the goals with the gui is to create something people can use for their own games, which means they need to be able to tweak as much as possible.

    This means padding rects, colors, icons etc need to be variables of some sort, and preferably collected together so they are easier to tweak. The mojox/theme.monkey2 file was my temporary solution to this but has been superceded by a much nicer ‘theme.json’ config file in the new mojox.

    I’m a bit curious why you duplicated the code for ‘TreeView’ in codetreeview – was there some reason you couldn’t just extend TreeView.Node? This is what I’ve done in debugview/helpview and it turned out to work surprisingly well. Or is it just another case of ‘no docs’?

    DrawImageIcon is possibly a useful addition to mojo, although it can also be achieved with DrawRect( x,y,w,h,image,sx,sy,sw,sh ). In future, when mx2 gets the ability to add methods to classes, you’d be able to implement DrawImageIcon without having to add more stuff to canvas.

    Everyone’s likely to have their own ‘must have’ version of DrawImage etc. If there’s enough demand for one in paticular I’d consider adding it, but it’s a ‘one off’ request and can be implemented without disturbing canvas it probably wont happen.

    I like the new Color consts and think they would make a nice addition – although ‘Phlox’?!?

    I don’t think the Key.Command addition is necessary – the ‘Gui’ key basically means ‘the key between Control and Shift’ and I’m fine with that. My Ps2 keyboard (still going!) has a ‘PS’ key for the Gui key – should I add another enum for that? I don’t think so…

    What is probably sorely needed though is something like:

    …to make setting hotkeys for menus easier.

    Nice work in general though! I’m amazed anyone has been able to do anything useful with mojox considering it is completely undocced and fairly underdeveloped so I understand it can’t have been easy to do what you’ve done.

    The new mojox will have SOME docs at least so hopefully my apparently ‘weird’ approaches to some stuff will make more sense.

    in reply to: Reflection when? #2662

    Mark Sibly
    Keymaster

    No ETA at the moment sorry.

    Get back to work on diddy in the meantime!


    Mark Sibly
    Keymaster

    I agree that String could do with some more methods, though I’m not too keen on the ‘L’ ‘R” names – how about…?

    Dup:String( num:Int )

    TrimStart:String()

    TrimEnd:String()

    Pad:String( len:Int,padding:String=” ” )   ‘centers string…? Symmetry with Trim()…

    PadStart:String( len:Int,padding:String=” ” )

    PadEnd:String( len:Int,padding:String=” ” )

    I’m thinking ‘Start’ ‘End’ instead of ‘Left’ ‘Right’ here to go with StartsWith and EndsWith, but ‘Left’ and ‘Right’ would also work.

    Not quite sure how padding:String works – Duped as much as necessary? – but it’d be nice to allow for more than just padding with spaces.

    I did consider allowing String * Int for Dup, but with the relaxed type conversions was a bit worried it could too easily trip people up. Still an option though…?

    in reply to: Questions about Monkey2 #2660

    Mark Sibly
    Keymaster

    How does it use emscripten when emscripten requires LLVM bytecode and Monkey2 compiles using gcc?

    Emscripten provides a full clang c++ toolchain for translating c++ -> llvm.

    1. Does Ted2 use OpenGL for rendering?

    Sort of. Mx2 uses the gles20 api for all rendering at the moment, but on Windows this is converted to d3d9/d3d11 via the ‘angle’ library.

    1. Performance wise… a blank canvas gives about half FPS that a blank canvas in BlitzMax would create.  Is that something to be concerned about?  Will the performance ratio be similar compared to BlitzMax (0.5x)?

    Hopefully not!

    in reply to: Fatal error on build: Broken declaration in scope. #2659

    Mark Sibly
    Keymaster

    Local blendMode:=BlendMode.Alpha *should* work – definitely a bug.

    Can you post this in ‘issues’ at github Richard? Just copy and paste of the original post is fine.

    in reply to: Some help with a mojox GUI #2592

    Mark Sibly
    Keymaster

    Sure – are they up at github yet?

    in reply to: TimelineFX not far off #2590

    Mark Sibly
    Keymaster

    @mark, any idea when the zip module might be ready to use?

    Very soon!

    I have a simple std.zipfile module already going, but all it can really do is ExtractZip( zipFile,dstDir ).

    I’ll be adding support for extracting individual files and subdirs too, but if all you need is ExtractZip I can commit ASAP.

    in reply to: Some help with a mojox GUI #2570

    Mark Sibly
    Keymaster

    I’m actually in the process of cleaning up mojox and turning it into a ‘real’ module – results should be out within a week or so.

Viewing 15 posts - 1,246 through 1,260 (of 1,431 total)