Jump to content




LuaLua - OOP Programming Language for CC. NEW - Anonymous Function Syntax


  • You cannot reply to this topic
60 replies to this topic

#21 tuogex

  • Members
  • 13 posts

Posted 16 October 2013 - 07:28 PM

I'm liking this very much. Definitely good for anyone who misses Objective-C-like classes in Lua.

#22 ElvishJerricco

  • Members
  • 803 posts

Posted 18 October 2013 - 02:27 PM

Updated the property system. Much more powerful now but restricted to working inside classes rather than in the global space. Re-read the properties section for more detail.

#23 Imque

  • Members
  • 134 posts

Posted 19 October 2013 - 06:45 PM

That is really nice code and functionality.. +1

#24 ElvishJerricco

  • Members
  • 803 posts

Posted 20 October 2013 - 08:19 AM

View PostImque, on 19 October 2013 - 06:45 PM, said:

That is really nice code and functionality.. +1

=) Thanks!

Anyway

I'm working on changing the syntax for methods a bit. It'll break old LuaLua programs but I think it's a little nicer.

-- instead of this
@[@[MyClass new] init]
@{globalCall}
-- it will be this
||MyClass new| init|
|@ globalCall|

Basically just replacing the weird @bracket system with vertical bars. Should work fine.

#25 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 20 October 2013 - 08:25 AM

View PostElvishJerricco, on 20 October 2013 - 08:19 AM, said:

I'm working on changing the syntax for methods a bit. It'll break old LuaLua programs but I think it's a little nicer.

-- instead of this
@[@[MyClass new] init]
@{globalCall}
-- it will be this
||MyClass new| init|
|@ globalCall|

Basically just replacing the weird @bracket system with vertical bars. Should work fine.
Won't really be inspired by Objective-C then will it :P

Also, just write a parser to support old versions by converting them into the new version. Perhaps the easiest solution is to have a header, if the file header is missing, parse it.

#26 ElvishJerricco

  • Members
  • 803 posts

Posted 20 October 2013 - 08:43 AM

View Posttheoriginalbit, on 20 October 2013 - 08:25 AM, said:

Also, just write a parser to support old versions by converting them into the new version. Perhaps the easiest solution is to have a header, if the file header is missing, parse it.

That's not a bad idea. And I still think it's Obj-C-like. Just uses a different ascii character =P

EDIT: Oh I should also note that declaring methods will be a little different.

-- instead of this
function @(methodName:param)

end
-- it will be this
function (methodName:param)

end
Basically just removing the unnecessary @ in front of the parentheses.

#27 ElvishJerricco

  • Members
  • 803 posts

Posted 20 October 2013 - 09:03 AM

There. Updated. Didn't include legacy support because it's not hard to adopt, and writing a legacy parser would have been harder than I expected.

#28 Wobbo

  • Members
  • 24 posts
  • LocationThe Netherlands

Posted 07 November 2013 - 12:40 PM

This is looking really nice! It reminded me of Obj-C before I saw it was modelled after it :P
As a name change, may I suggest Objective-Lua? Since it is so heavily inspired on Objective-C.

#29 ElvishJerricco

  • Members
  • 803 posts

Posted 07 November 2013 - 01:44 PM

View PostWobbo, on 07 November 2013 - 12:40 PM, said:

This is looking really nice! It reminded me of Obj-C before I saw it was modelled after it :P/>
As a name change, may I suggest Objective-Lua? Since it is so heavily inspired on Objective-C.

Thought about that. All in all, LuaLua isn't meant to be Object Oriented Lua. It's supposed to be an extension of it, hence a name that appears to just extend Lua.

#30 robhol

  • Members
  • 182 posts

Posted 09 January 2014 - 12:24 PM

How feasible would it be to fork this and instead base the syntax on something that... well, isn't ObjC?

#31 ElvishJerricco

  • Members
  • 803 posts

Posted 16 January 2014 - 10:35 PM

View Postrobhol, on 09 January 2014 - 12:24 PM, said:

How feasible would it be to fork this and instead base the syntax on something that... well, isn't ObjC?

You don't have to use the ObjC syntax. Conventional lua syntax still works.

@class A:LuaObject
	function myInstanceMethod()
		print("Works like a charm")
	end
end

local obj = A.new().init()
obj.myInstanceMethod()

Any function that doesn't take parameters is under the same name as it would normally be so new and init work fine, and there's no other functions built in except the subclass method which has no reason to be called manually. So if you don't want to use the new syntax you don't have to (unless your working with someone else's code who does use it). And even when there are parameters you can still access the method in vanilla Lua syntax.

NewClass = SuperClass["subclassWithClassInstantiator:andObjectInstantiator:"](function(self, super)
	-- static closure; same as body of the optional @static block
end, function(self, super)
	-- instance closure; same as body of class block
end)

This example also demonstrates creating classes without the LuaLua syntax.

Anyways three fourths of the work in LuaLua is compiler work, while the other fourth is runtime work. So if you're willing to redo almost all the work I've done for the sake of using the same runtime with your own syntax, go ahead.

And finally, objective c syntax is really nice. I'm curious why you don't like it. It's very descriptive of the method parameters and closing things in brackets this way looks a lot better to me.

Edited by ElvishJerricco, 16 January 2014 - 10:38 PM.


#32 ElvishJerricco

  • Members
  • 803 posts

Posted 28 February 2014 - 07:44 PM

Is anyone actually using? I'm considering pulling it from my github and just designing a language that isn't bootstrapped to Lua.

#33 blipman17

  • Members
  • 92 posts

Posted 04 May 2014 - 09:38 AM

I would like to use it, but i would need a bit more documentation about objects. I understand the idea behind them and their power but can't use them due to lack of knowledge. Even if this is a death thread it would be a shame if it went to waste.

#34 Sir_Mr_Bman

  • Members
  • 62 posts

Posted 25 May 2014 - 03:35 PM

Just dug this up.

As someone who knows Objective-C, this looks rather nice!

Gonna have to try it out!!

#35 ElvishJerricco

  • Members
  • 803 posts

Posted 04 June 2014 - 04:33 AM

View Postblipman17, on 04 May 2014 - 09:38 AM, said:

I would like to use it, but i would need a bit more documentation about objects. I understand the idea behind them and their power but can't use them due to lack of knowledge. Even if this is a death thread it would be a shame if it went to waste.

I apologize for the incredibly late response. I've taken quite an absence from minecraft in general lately... Anyway what isn't clear about objects? I can try to make it more clear in the post.

#36 ElvishJerricco

  • Members
  • 803 posts

Posted 05 October 2014 - 06:59 AM

LuaLua is now a Grin-Get package.

Edited by ElvishJerricco, 05 October 2014 - 06:59 AM.


#37 ElvishJerricco

  • Members
  • 803 posts

Posted 07 October 2014 - 12:42 AM

New anonymous function syntax in the latest version.

somethingThatTakesAFunction(\(p1, p2, ...) print(...) end)


#38 ElvishJerricco

  • Members
  • 803 posts

Posted 04 November 2014 - 05:41 AM

Updated. Bug fixes

#39 DigitalMisha

  • Members
  • 9 posts

Posted 02 January 2015 - 12:51 PM

Are there any IDEs or just editors for LuaLua? It is very hard to write on such language without specified editor.

#40 ElvishJerricco

  • Members
  • 803 posts

Posted 03 January 2015 - 10:02 PM

In my experience, editors aren't really that important for writing with a language. They're really nice but it's not hard to do without one.





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users