Forum Replies Created
-
AuthorPosts
-
The problem with bool->string conversion is that since string->bool is true if string is non-empty (which IMO is the right way to do it), then for Bool(String(Bool)) to produce the correct result (ie: should give same value as the original bool) bool->string needs to produce “” for false. Which means Print Bool( blah ) could print ‘nothing’ which I’m not comfortable with.
Or…if bool->string produced “true”/”false” or something, then Bool(String(Bool)) would always return true!
I have never really come up with a good solution for this (mx1 did it too) but I DO know I much prefer the simple ‘non-empty-string-is-true’ string->bool conversion as it’s easy to remember and IMO more useful in practice, than attempting to parse “1” or “true” or “True” etc as true.
Think I prefer ‘as opposed to’.
The problem I have with the first one is it’s just a string of ‘stuff’. At least in c++ you get the enclosing ‘{‘ ‘}’ to delimit the lambda scope from the expression scope, even if it’s on the same line.
September 5, 2016 at 7:16 pm in reply to: external abstract won't compile in debug mode (w7 and elcapitan) #3684Fixed on github, but there’s likely to be more like this – keep reporting them thanks.
Sorry, that should have been ‘not’ – it was late.
Maybe it’s just my inexperience with lambdas, but the short form looks like a minor ‘win’ at the cost of making the code look a lot more obsfucated. It’s just not very monkey-like IMO.
Maybe it’ll grow on me (it has a tiny bit) but right now I just don’t see the need for it.
Probably not gonna accept it – I ‘m fine with current syntax and find ‘shortcut’ lambdas one of the hardest things to read in other languages.
Just commited some changes that might fix some of these issues.
The basic problem appears to be that SDL_CaptureMouse on linux gets a bit carried away!
OK, the main problem with the audio is that you’re not discarding channels, and it looks like openalsoft has a hard max channels limit (although not macos openal?).
Basically, if you New() a channel, you’re also expected to Discard() it.
The Sound.Play method does this automatically (ie: once the sound finishes playing, the channel is auto-discarded) but this doesn’t easily let you setup rate, pan etc before the sound plays.
One option would be to add a bunch of params to Sound.Play, but this seems messy and not very future proof so a better way may be to add something like ChannelFlags that let you specify ‘AutoDiscard’ or something. Will have a look…
Thanks for uploading the new module too – got to make sure it works with the next ‘release’!
Extensions are ‘getting there’ (there’s a first attempt in the next release) but it’ll be a while yet before you can use them with Array<T>. Should ultimately be doable though.
You’ll need the latest repository version of my framework, I added some stuff to it lately.
Can you do a module manager update for this, or is not ready yet?
Probably not, but it could possibly be made to work in some situations.
If it’s just a plain ‘infer type from params’ generic method that ends up looking like a plain method call in use, it might be doable.
But if you are wanting to explicitly specify the type via eg: blah<Int>() there’s currently no way.
Monkey2 generates it’s own generic instances, so by the time everything hits the translator there is not a lot of generic info left. The translator doesn’t use any of it anyway.
> I have one problem though, and it’s with audio, on Linux.
Have to see the code before I could even make a guess! Hint, hint…
private is not accessible to overriden methods declared in mx2 (may be the same when just overriden)
Use ‘Protected’ instead for when you want only subclasses to be able to access members.
you can’t pass by reference to pure virtual methods that had been implemented in mx2
This is because mx2 has no concept of ‘const &’ so there is no way it can generate c++ code with ‘const &’ params.
So your MyVM(i:Int) override does not in fact override the native superclass method (which takes a const int& param), so the superclass remains abstract.
The best solution in this case is probably to create a glue class for problematic methods like this, eg:
Monkey12345678910111213141516171819202122// c++class Foo_glue : public Foo{//mx2 incompatible!virtual void MyVM( const int &i ){//pass to mx2 compatible version...MyVM( i );}//mx2 compatible!virtual void MyVM_glue( int i ){}};' mx2ExternClass Foo Extends Void="Foo_glue"Method MyVM( i:int ) Virtual="MyVM_glue"EndIt’s kind of ugly, but you only have to glue up the non-mx2 compatible methods. I did something like this for litehtml and it wasn’t too bad.
Or, if you can find a ‘C’ wrapper, that’s probably even better!
I’m not sure why the author went with ‘const int&’ here in the first place (or perhaps this is just a test case?) – plain ‘int’ would do the same thing and be faster (and be compatible with mx2!) – but that’s c++ for you. There are just so many ways to do things it’s all too easy to pick a crappy way without even knowing it.
Unfortunately, this wont work in every case, eg: with factory systems where you don’t get a chance to subclass. But it should work for this.
I ultimately intend to use libclang or swig to write a c/c++ extern generator (I actually think this should be quite high priority, but I’ll get the mobile stuff out of the way first) which will help with writing lib modules and perhaps SOME of the glue stuff, but there will likely always be problematic c++ types.
Actually, I sort of agree with nerobot here – but not completely!
‘x’ and ‘y’ are already available as public fields – I consider this OK *because* you’re (almost) always working with your own copy – and perhaps having the setters just confuses things as it prevents the compiler catching situations like the above?
On the other hand, setters that do more than just set one field can be useful – eg: the ‘TopRight’ (which sets max.x and min.y) setter for Rect, so perhaps there’s not really a ‘right’ answer to this problem.
I did actually spend a fair bit of time trying to come up with solutions for this because I knew it would trip people up, but I couldn’t think of anything that wasn’t going to either take ages to implement (and possibly not even work) or involve adding a bunch of weird ‘Const’ stuff to the language.
But I’m happy my explanation makes sense!
I’m asking where is the ‘correct place/way’ to insert this checking/altering thing in the current TED2 structure
There should be a ‘Ted2TextView’ in there which is currently responsible for calling the textview plugins – this is probably a good place to start tinkering as there’s not much in there.
Perhaps the TextViewKeyEventFilter plugin should be replaced with a simpler ‘TextViewPlugin’ that provides the same virtual methods as TextView, ie: OnKeyEvent, OnMouseEvent, OnRender? Perhaps not as easy to use as something more specific, but more flexbile (and you can always subclass it for a more specific superclass). TextViewPlugin could also perhaps provide a set of file types it’s applicable for (eg: there may be c++ specific textview plugins etc).
Also using of plugins has some limitations – if you need to get data from file while initialize plugin – inside of method New() – you get “Memory access violation” er
Will add an OnCreate() for this that gets called once everything’s up and running.
And how to control plugins collisions?
For document type plugins, there will need to be a way for the user to select the ‘default’ document type to be used when doing a plain ‘Open’. I can probably hack this into a menu somehow, although it probably belongs in a ‘real’ IDE options dialog – coming one day…
For the file tree view RMB menu, an ‘Open With’ menu item could also be used to open documents with a different plugin.
For textview plugins, you’re kind of boned aren’t you? Although it might also be an idea to think about plugin priorities?
No problem – it’s open source, you can do whatever you want with any of it!
mojox will continue to evolve, but it’ll be a slow process as I have other 1001 things to do as well.
Things generally get added when I need them, eg: I’m working on ‘project settings’ right now which means I will be adding some sort of ‘combo box’ tomorrow – not really looking forward to it!
-
AuthorPosts