Venrob04/25/2019
Notice the Would be nice tag; we have no plans to even implement this at this time
part of the syntax is limited by the bison, as well, due to shift-reduce and reduce-reduce errors
one of the reasons casting is <type> instead of (type)
Mr Mustache04/25/2019
ok thats just one of the things I hate in c++ is the * and &
Venrob04/25/2019
I understand the feeling, because they always confuse me
but, they are actually very important in what they allow
Mr Mustache04/25/2019
what is even the point in pointers if you can pass by refrence?
like idk why anyone would need a pointer
ZoriaRPG04/25/2019
Erhm, I needed one many times today.
Look at all of my commits from today and yesterday in branch 2.55.
I use pointers everywhere.
Mr Mustache04/25/2019
hmm is it needed for scripts though?
i guess functions as variables could be handled internally on assign
so you don't have to use *
anyways I got to get off
gn
ZoriaRPG04/26/2019
@Mr Mustache : This might be useful to you:
http://www.cplusplus.com/doc/tutorial/pointers/
In ZScript, the logical way to handle a function pointer, would be fpr the pointer to reference the ZASM instruction line on whichn the function begins.
We don't have certain elements such as an address system, just ZASM line IDs.
When we call a function in ZScript, we jump to its line, so, a function pointer would store that line.
and when called, we would jump to that line, until we reach OReturn
Of course, we'd also need to store the types and number of params used by the function pointer, in addition to its ZASM line address somehow.
This could probab;y take a similar form to how array data works. Store the 'size' in index 0, the 'address' of this segment (pointer) in index 1. then for each arg, an index for its type.
Thus, the pointer would look like this:
(*fun)(int,bool,bitmap)
{4, &fun, TYPE_FLOAT, TYPE_BOOL, TYPE_BITMAP}
The first index tells us how far into the vector from this point we are reading. The second is the ZASM line number, and the last tell us how to cast its values. We may need additional space to store them when called.
The actual initialisation of a function pointer:
void(*foo)(int,bool,bitmap); would push onto the stack, a flag that the next stack value is going to be a function pointer, then the array address in the vector.
@Venrob Feasibility?
It would have been better if our syntax always required pointer tokens for this sort of thing, because the way that we pass arrays by reference is exactly why it is hard to fix some of their problems, and a cause for not being able to ever migrate away from how they now work.
Thus, if we ever want real structs, 2D arrays, or classes, we would need some kind of address system for those.
In that case, the pointer would be the starting point of the struct/array/class in a vector.
as v->at(address)
ZoriaRPG04/26/2019
The benefit of function pointers, is that you can do stuff like this:
Mr Mustache04/26/2019
I would perfer the at(address) then using *
ZoriaRPG04/26/2019
PSEUDOCODE ALERT
int(*global_set_ghost)(void) = Ghost_Main;
int (*global_set_tango)(void) = Tango_Main;
int global_loop[1024]; int highest_global_call = 0;
global script init_add_ghost //if we have multiple init scripts, each can add stuff to the global active
{
void run()
{
global_loop[highest_global_call] = &global_set_ghost;
++highest_global_call;
}
}
global script init_add_tango //if we have multiple init scripts, each can add stuff to the global active
{
void run()
{
global_loop[highest_global_call] = &global_set_tango;
++highest_global_call;
}
}
global script active
{
void run()
{
int f;
while(1)
{
for ( int q = 0; q <= highest_global_call; ++q )
{
f = &global_loop[q];
f();
}
}
}
}
I would perfer the at(address) then using * Except, you can't KNOW the address until runtime.
Now, you could use a literal token of (at), or something.
even @ or $
Mr Mustache04/26/2019
at and ref like...
ZoriaRPG04/26/2019
Different languages have different tokens to represent a pointer.
and an address ID
@ is used for handles
Mr Mustache04/26/2019
int x = 25
int y = ref x
int z = at y
ZoriaRPG04/26/2019
IIRC
Those would just be alt tokens.
Like and for &&
Mr Mustache04/26/2019
there is no way to force them to be in ()?
int x = 25
int y = ref(x)
int z = at(y)
ZoriaRPG04/26/2019
Oh
no, C++ HANDLE is typedef'd
Mr Mustache04/26/2019
oh ok :(
ZoriaRPG04/26/2019
So, there you go.
typedef void *HANDLE;
typedef void* ptr
Mr Mustache04/26/2019
well now that I know that a pointer is a way to get a variable from a refrence
its not so bad
@ would be nice for *
ZoriaRPG04/26/2019
It's a way to get either the address of a variable, or the value stored at a particular address.
Mr Mustache04/26/2019
as an alias
oh i see
ZoriaRPG04/26/2019
Most scripting systems don't also have an address system, or a heap.
True programming languages need these.
Especially if you want dynamic memory management.
Mr Mustache04/26/2019
ya i understand
can you at least implement the @ alias though?
it seems more clear
because its the literal at symbol
ZoriaRPG04/26/2019
I would prefer to keep things to C syntax, because that way, people can look up basic C docs and learn the language.
Mr Mustache04/26/2019
ok
ZoriaRPG04/26/2019
Also, @ has other connotations, however, because of how flex works, who knows if we can ever get * or & to work.
Mr Mustache04/26/2019
I wonder why c++ didn't do it
oh ok
ZoriaRPG04/26/2019
making rules so that they are detected as pointer tokens and not as mult or bitand, isn't trivial.
I suppose as long as the left side is a type, it'd be fine, for *
Just even more complex OoO stuff.
Mr Mustache04/26/2019
uhh I have a question
is zscript compadable with C#?
like could it be made into a library for me to use?
ZoriaRPG04/26/2019
I don't know enough about C# to tell you if it'd port over.
IDK if flex-bison can be used in conjunction with C#
Mr Mustache04/26/2019
oh ok
ZoriaRPG04/26/2019
You should just just something better anyway.
Mr Mustache04/26/2019
well I might just do lua where I make a visual and C style converters
that convert it to lua
ZoriaRPG04/26/2019
C# has its own .NET scripting language.
So, you could just use that.
Mr Mustache04/26/2019
ya I know
:(
ZoriaRPG04/26/2019
C# can be its own scripting language, so IDK why you would ever use something as system-heavy as ZScript if you are already using C#
Mr Mustache04/26/2019
lua would be easier to make a visual scripting laguage with I think
because the code widgets could just be lua snippits
I just hate the then end
ZoriaRPG04/26/2019
Eh
I actually prefer that. it's Pascal syntax.
Mr Mustache04/26/2019
ya i know we have had this discussion before :P
I saw this thing were a team of people made a c style lua scripting language
I think its called bright
but I don't like how they do types at the end of the declaration instead of the beginning
function foo() : void
end
I think thats how it went
ZoriaRPG04/26/2019
What you could do, is make a scanner as a preprocessor that reads an input file, and appends the C# tokens to a C style syntax.
That however, would slow down code excution considerably just because you don't like the syntax.
I would advise against it.
That's also based on pascal.
http://wiki.freepascal.org/Function
Venrob
Adding class to ZScript
If @Venrob manages to get namespace working, fully, then I don't think that this will be as big of a bitch as he imagines it would.
(A) ZScript will not need, nor be able to use multiple instances, so we can dispose of new m and instance behaviour, and focus on the following:
(B) Inheritence
A class should be able to inherit variables, and functions from its parent. In essence, it would be like appending one namespace to another, for its internal instance.
(C) Polymorphism
This one is trickier, but in essence, we'd need to allow a shadow declaration to take precedence. If youhave the following classes:
class foo
{
public:
int x;
};
class bar : public foo
{
public:
int y;
};
...then both bar.x and bar.y are legal, as is foo.x, butfoo.y is not legal.
(D) Function and Variable Storage Types
public and private
We'd need to mark if a function is private, and thus, only available to that class.
We wouldn't need protected.
I'd rather have structs, but I do like the idea of adding the ability to create inherited and polymorphed functions and variables, at some point.
Structs have the same issue as real 2D or 3D arrays.
The issue with storage comes down to storing data in a save file.
You don't save instances. They are allocated onto the heap only during operation.
We also don't have a heap, and you'd never properly reconstruct that heap to recover them, from the save file, without losing the correct address pointers
Look at how array data is stored when you want.
I think that 2D arrays, using a new type specifier, might be viable, and if they ever are, then structs may also be; but of course, then we run into potentially needing real pointers and other stuff. IDK
2D arrays, structs, that might one day be viable:
IIRC, Array data is all stored in a vector that contains first the array pointer, then its size, then its data.
2D or 3D would need to contain the different dimensions, and the data in the correct sequence.
structs would need to store the struct pointer, the number of members, then the datatype of each member, the size and dimensions of each member, and then the data.
As I said, inheriting data member access is something that I'd like to have, but I can live without it.
I'm just putting the whole thing there for you, to archive it, with some contextual corrections.
Mr Mustache04/25/2019
so i know this says would very much be nice but if this was implemented wouldn't it be cleaner and more clear to do..
class foo
{
public int x;
public int y;
};
rather then
class foo
{
public:
int x;
int y;
};
this is another thing I hate about c++ although c++ ide's are the ones forcing me to use the second one
I could easly do..
class foo
{
public: int x;
public: int y;
};
Venrob04/25/2019
Again, inactive channel
this entire category is
ZoriaRPG03/24/2019
2D arrays, structs, that might one day be viable.
Array data is all stored in a vector that contains first the array pointer, then its size, then its data.
2D or 3D would need to contain the different dimensions, and the data in the correct sequence.
structs would need to store the struct pointer, the number of members, then the datatype of each member, the size and dimensions of each member, and then the data.
Venrob03/24/2019
My main issue is I know almost nothing about the ASM side, or anything related (including save file stuff)
I don't think I've even added an opcode, that got merged (KoolAid and I did the TriComp, as a test to learn how the parser worked, but that's not getting merged, because we don't want it)
That was part of the discussion.
Not sure where I detailed the rest.
(*fun)(int,bool,bitmap)
{4, &fun, TYPE_FLOAT, TYPE_BOOL, TYPE_BITMAP}
The first index tells us how far into the vector from this point we are reading. The second is the ZASM line number, and the last tell us how to cast its values. We may need additional space to store them when called.
that was for function pointers, though
ZoriaRPGToday at 1:06 AM
aaaah
#????classes-with-instances
Attachment file type: document
zscriptstructmodel.txt
10.47 KB
i think those were all of my models.
I'm syure that at some point I typed out a vector format, though.
ZoriaRPGToday at 1:18 AM
structs would need to store the struct pointer, the number of members, then the datatype of each member, the size and dimensions of each member, and then the data.
Found it
on the script server
Still missing where I typed it in an array format
{ pointer, number_members, { member types }, { member sizes }, { member data } }
stored in a vector
IDR if you can search a vector for a 'substring'
if you can,then pointer should be a string like $1000
that way, the zasm stringsearches the vector for $1000 and gets the ->at() index of the pointer
that, or pointers need registration regularly
oh
or
skip that index
this needs to ve a vector of vectors
so, the pointer is the entry point in the D2 vector containing the vector of data
thus
STRUCT
{ vectors } == pointer
{ vectors { number_members, { member types }, { member sizes }, { member data } } }
2D array
{ vectors } == pointer
{ vectors { { types }, { sizea, sizeb }, { data,data,data... } }
Comments