Any kind of variable as a function parameter?

BlitzMax Forums/BlitzMax Beginners Area/Any kind of variable as a function parameter?

Mr. Write Errors Man(Posted 2010) [#1]
I thought I had done this previously (I think by using reflection) but I can't find my old code and forum search doesn't give me anything.

It boils down to basic data types not being objects, so you can't pass for example Int as a parameter when Object is expected.

Of course I could go around by making wrapper types or converting to Strings etc but I'd rather not.


Otus(Posted 2010) [#2]
What exactly are you trying to do? This may not be the best way to go about it. Reflection also converts numbers to Strings in between.


Mr. Write Errors Man(Posted 2010) [#3]
I am toying with the idea of separating storage, data, layout, rendering, logic etc into an abstract framework.

I started similar project a good time ago but now I can't find the code any longer. I thought I had found a way to the base types / Object dilemma, but perhaps my mind is playing tricks on me.

Perhaps I just need to swallow the bitter pill and make a custom type for holding variables.


Czar Flavius(Posted 2010) [#4]
Variable wrappers aren't the end of the world!


Jesse(Posted 2010) [#5]
what Czar Flavius said plus it will more than likely be faster than using reflection anyway.


Mr. Write Errors Man(Posted 2010) [#6]
Speed is not an issue, because it would not be optimal anyway due to multiple abstract layers.

The danger with variable wrappers is the temptation to make variables abstract as well. Require data source, event or state connection for all variables, applying inter-variable events, validators and separate abstract logic modules.

As should be apparent, I am more interested in toying with the theory rather than making an application using the framework.


Czar Flavius(Posted 2010) [#7]
I think you are over-thinking!


Mr. Write Errors Man(Posted 2010) [#8]
I am not planning to make some app with my tests or even expecting to ever make the framework to the level of being something useful. It's just strange but relaxing brain fun.

For years I was totally annoyed when I encountered these kind of high level frameworks at work. They are so confusing and bloated, if compared to X = X + 1 type code. But little by little I am starting to "get it".


Warpy(Posted 2010) [#9]
Have a look at my code archive entries if you want to see how hideous this kind of generic code can get in BMax.


Mr. Write Errors Man(Posted 2010) [#10]
Some interesting stuff in there Warpy!

Yes, it can get hideous. Besides the base type problem, the lack of method pointers doesn't making this kind of stuff any easier. I suppose one could just as well make a totally new variable and class system on top of the native BlitzMax one. Not necessarily the sanest thing to do.

BTW by coincidence I was thinking yesterday about making a RegEx module but I see you already did it. Good work. :)


Czar Flavius(Posted 2010) [#11]
You can sometimes get around the lack of method pointers - what are you wanting to do?


Mr. Write Errors Man(Posted 2010) [#12]
Yes I know you can get around it by using functions with types as parameters etc.

There isn't anything specific I am wanting to do, other than have some code within a method call some method of some other type as defined by the user. Not that it would be usable anyway, because of the issue with parameters. It's more practical to make your own variables, classes and methods out of dozens of types. But then again, that's crazy. I have considered making some of it process thru JavaScript with MaxGUI's HTML gadget. :)

BTW I am not criticizing BlitzMax. It's a great language. What I am trying to do is a bit silly.


Czar Flavius(Posted 2010) [#13]
What about using the SendMessage method, that is available to any object?


Mr. Write Errors Man(Posted 2010) [#14]
Hadn't thought of that. That's a good idea worth looking at. Thanks Czar Flavius! :)


ImaginaryHuman(Posted 2010) [#15]
What about passing a pointer to the variable and another variable holding its type?


Mr. Write Errors Man(Posted 2010) [#16]
Perhaps, though I think you could as well use variable wrappers.

Coding this is becoming a pain. The silly fun element is dying fast. I think I need to find something else to toy around with.