eJimLee / VarObject

Provides a variable class with weak type.
BSD 3-Clause "New" or "Revised" License
1 stars 0 forks source link

Advice needed #1

Open IngwiePhoenix opened 9 years ago

IngwiePhoenix commented 9 years ago

Hey.

Im trying to write a class that interfaces a scripting language's dynamic typing - but I am terribly stuck. x)

Appearently, in C++, I can not define multiple functions that differ only in their return type but otherwise have the same declaration.

And, I also can't seem to create a private subclass that I could return, that then could have operators to cast into the specified types. It just does not really want to work.

So I'd like to know if you could give me a tipp on doing that?

Here's some information about the scripting language I am trying to interface:

It's here: https://github.com/unitpoint/objectscript

I mainly want to do that, in order to be able to create a reference to a scirpted function, so I could store it. Actually, Im using VarObject in the same project already that I want to use the script-type interface at.

So if you have any tipp for this, it'd be nice to learn about it =)

Kind regards, Ingwie

eJimLee commented 9 years ago

I am so sorry for wasting your time. I can’t provide more opinion to you that help your project.

First, I'm sure that VarObject is not suitable for you. In fact, I just want to know whether I can implement a class that is operated without caring about type, on the beginning. So that is unstable and unreliable. I don’t think that can be used on formal project. Second, I have found that VarObject have so much confine, such as low performance, wasting memory etc. I don’t think I can solve them considering spare time and my ability. It’s the most terrible that you take too much time to getting enough benefit from VarObject on a complex project. Finally, the VarObject class should not be used by pointer, that will cause serious leaking memory. It just safely work nice while using “return VarObject()”. In fact, this is reason that VarObject cause low performance. Also it should not be used as parent class, that isn’t support by C++ because of C++ class implement. You will get wrong result while using subclass or cast subclass to VarObject.

In a word, there are so much confine on VarObject, we can’t use it as parent class or pointer comfortably. Maybe you think about implementing better one or trying other way.

Kind regards, eJim Lee

2014-10-04 7:44 GMT+08:00 Ingwie Phoenix notifications@github.com:

Hey.

Im trying to write a class that interfaces a scripting language's dynamic typing - but I am terribly stuck. x)

Appearently, in C++, I can not define multiple functions that differ only in their return type but otherwise have the same declaration.

And, I also can't seem to create a private subclass that I could return, that then could have operators to cast into the specified types. It just does not really want to work.

So I'd like to know if you could give me a tipp on doing that?

Here's some information about the scripting language I am trying to interface:

  • It has a stack-based VM
  • Values, except NULL, boolean and numbers, are idendified with an ID that can be obtained (getValueId(int offset))
  • Values can be retained and put into the stack by their ID.
  • Available types are: NULL, Bool, Number (int, float), String (Object: "string"), Array, Object, Function
  • There are methods such as toString(), toBool(), etc.

It's here: https://github.com/unitpoint/objectscript

I mainly want to do that, in order to be able to create a reference to a scirpted function, so I could store it. Actually, Im using VarObject in the same project already that I want to use the script-type interface at.

So if you have any tipp for this, it'd be nice to learn about it =)

Kind regards, Ingwie

— Reply to this email directly or view it on GitHub https://github.com/eJimLee/VarObject/issues/1.