Jump to content
Sign in to follow this  
Rophs

MDScript Object Oriented Programming

Recommended Posts

Sadly the closest you can get to it is arrays, as far as I know. You can't even define your own functions.

 

Edit: You can define your own functions.

Edited by samon

Share this post


Link to post
Share on other sites
I tried playing around with MDScript a little more and apparently you can use functions. That being said I haven't found a way to use variables from outside a function (other than passing them as parameters and returning them) inside the function. In that sense it is more like functional programming than OOP. Also it doesn't appear to be possible to use MDScript specific methods inside a user defined function.
 
e.g: 
function bar()
{
    echo @vv; //Always echoes nothing
    @vv = 'bar';
}
 
@vv = 'foo';
bar();
echo @vv; //echoes foo
 
function baz(@vv)
{
    @vv = 'baz';
    return @vv;
}
baz(@vv);
echo @vv; //still foo
 
@vx = baz(@vv);
echo @vv; //still foo
echo @vx; //vx is now baz
 
function err()
{
    echo uv('id');
}

err(); //Gives an error because uv is undefined

Edited by samon

Share this post


Link to post
Share on other sites

That being said I haven't found a way to use variables from outside a function (other than passing them as parameters and returning them) inside the function.


Tried using global keyword?

Also it doesn't appear to be possible to use MDScript specific methods inside a user defined function.


Tried passing them in?

Share this post


Link to post
Share on other sites
Global is a restricted keyword (thrice even) so that doesn't work.

As for passing in the methods, you can pass in the return values, but other than that not sure how it would work. (It is, for fairly obvious reasons, not possible to call a method stored in a variable, if that is what you mean.)

Share this post


Link to post
Share on other sites

Global is a restricted keyword (thrice even) so that doesn't work.


I shall add that to my list to review. we can probably expose the functions by default or via namespacing.

As for passing in the methods, you can pass in the return values, but other than that not sure how it would work. (It is, for fairly obvious reasons, not possible to call a method stored in a variable, if that is what you mean.)


Not possible in MDscript, or PHP? http://php.net/manual/en/functions.variable-functions.php

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Forum Statistics

    15,832
    Total Topics
    173,490
    Total Posts
  • Recently Browsing

    No registered users viewing this page.

  • Upcoming Events

    No upcoming events found
  • Recent Event Reviews

×
×
  • Create New...