Re: My scripting language - any suggestions?



Yeah, I thought about it. You're right. ToFloat is not scalable. Maybe
something like: To(Float), To(Type)? It's something between
my .ToType() and the 'to' operator proposed Johannes. Every solution
is better than the ugly (SomeClass)var).SomeMethod() ;) The preference
is to use as few (key)word operators as possible. I'm also thinking
about changing new Class to Class.New() or Class.Create(); It would
create a rather consistent interface with methods like object.Clone()
and maybe object.Destroy(). Also the general idea is that all objects
inherit some general methods from the base object called
'Object' (like Java and C#). The methods can be overridden depending
on the type:

- bool Is( Type )
- bool Instance( Type ) or Of( Type ) or InstanceOf( Type )
- Object To( Type )
- String Serialize();
- bool Unserialize();
- Object Clone();
- void Destroy();

As for the int and float representation... the Value class takes care
of that stuff. It's written in C++ and goes something like this:

[code]
class Value
{
public:
Value();
Value( Value& value );

Value& operator =( Value& value );

void SetNull();
void SetBool( bool b );
void SetInt( int i );
void SetFloat( float f );
void SetString( String* s );
...................................

public:
int type; // NULL, BOOL, INT, FLOAT, STRING, ARRAY, REF, OBJECT,
FUNC, ect
union
{
bool b;
int i;
float f;
} ;
Object* o; // everything else
};
[/code]

It's rather simple, but it works. Most scripting VM work that way.

As for the Serialize and To(String) methods, I find them distinct.
I.e. someone wants to display a float to the user, they do
var.To(Float) and get '1234.0987'. But if someone wants to write the
data to a file Serialize would return 'f:1234.0987' or 'float:
1234.0987'. The thing is I think the type:value can be parsed more
easily than just value.
.



Relevant Pages

  • Re: nativeMethod error
    ... private void InitializeComponent() ... public int cmdID; ... bool TopLevelContainer ... string LocationName ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Getting notification for dynamically added controls
    ... BOOL SetMatrix; ... void SetSliderRangeMinMax; ... int m_nScrollPos; ... BOOL UpdateDataPart(int k, BOOL bSaveAndValidate = TRUE); ...
    (microsoft.public.vc.mfc)
  • ToolTips in a View and TTN_NEEDTEXT
    ... extern int g_minWorkPeriod; ... void CDayView::CreateAllFonts ... void CDayView::DrawDayLog(CDC* pDC) ... BOOL CDayView::TimeToY ...
    (microsoft.public.vc.mfc)
  • met problem in touch panel driver
    ... static void TouchPanelPowerOff; ... INT CurrentSampleRateSetting = 0; ... //short int InitAcLink(volatile GPIO_REGS *, BOOL, BYTE); ... // unsigned int ier; ...
    (microsoft.public.windowsce.platbuilder)
  • Pyramid: Why does Switch Case WM_MOUSEMOVE not work for me?
    ... float g_fSpinX = 0.0f; ... bool initWindow; ... void createCamera; ... creates a virtual camera ...
    (microsoft.public.win32.programmer.directx.graphics)