Cool! The syntax reminds me of Lua, but also a bit of Matlab. Why do function calls sometimes have parentheses and sometimes not? Do you already have plans on how to interfere with C++?Yeah, the syntax is very oriented to Lua, but there are still significantly differences in the language design and the inner workings behind.
And have you implemented a garbage collector? I'm interested in how you manage resources and memory :)
That strikes me as confusing. No more confusing as some of the things other languages to do with functions as 1st class objects, but confusing none-the-less.New languages might always be confusing :P
Parentheses around function parameters are optionally. At least, if a function call (or definition/implementation) is not in an expression, i.e. you are not taking a function's return value for something.Do you see an advantage in making parentheses optional? Especially if you want to keep it simple, enforcing parentheses for function calls, and therefore avoiding the ambiguity, might be a better idea. At least, I find it quite unintuitive when an expression behaves completely different just because it is assigned to an object...
At the moment SilverScript uses reference counting, although I've already read that this kind of garbace collection might not be the best.Yes, there are some issues, especially circular references. There are different approaches, complex GCs work in "generations" depending on the object lifetime. I wouldn't make it unnecessarily complex, unless you need a high-performance scripting language ;)
New languages might always be confusing :P
Parentheses around function parameters are optionally. At least, if a function call (or definition/implementation) is not in an expression, i.e. you are not taking a function's return value for something.Do you see an advantage in making parentheses optional? Especially if you want to keep it simple, enforcing parentheses for function calls, and therefore avoiding the ambiguity, might be a better idea. At least, I find it quite unintuitive when an expression behaves completely different just because it is assigned to an object...
I think that function calling without parentheses is a bad idea.
Well, worked in Basic, too. But I agree, it could be misleading/harder to read and you don't gain anything making the parenthesis optional, so I'd just force them, especially when supporting some kind of pointers or references (to distinct between wanting the address or return value for example). Otherwise things like "x = functionname" will be misleading, especially for beginners, cause most would expect the return value to be assigned.
I made the parentheses in general optionally, because I find it nicer to read or to understand in some cases, especially if the function doesn't have any parametersExactly in these cases, I find it very misleading. This is also the case in Matlab, and I have been confused again and again because you can't syntactically differ between variables and function calls in the code. What makes things even worse in Matlab, is that the array index operator and function call operator look exactly the same.
Most of you are just too used to C style languages, where parentheses around function parameters are needed.I have already programmed in Haskell, where everything is a function. Function calls require no parentheses. But contrary to SilverScript, this syntax is consistent inside Haskell.
The same rule applies for arrays: when accessing/setting an index with the []-operator, the variable is internally converted to an array, and any previous data (e.g. class attributes) is deleted.The initialisation of members without initialisation of the object exists also in Matlab :)
There are some other language aspects, I would like to discuss more. In SilverScript, a Class is the same as an Object, Namespace or Structure. An object is just a copy of a class (function code internally keeps referenced) and could be used a sub class which could also be instanciated (so, copied).Do you somewhere differ between the 4 terms?
As far as I know, parentheses in function calls in Ruby aren't needed, either, am I right?
There are some other language aspects, I would like to discuss more. In SilverScript, a Class is the same as an Object, Namespace or Structure. An object is just a copy of a class (function code internally keeps referenced) and could be used a sub class which could also be instanciated (so, copied).Do you somewhere differ between the 4 terms?
If an instance is just a copy of a class, can you change the original class? In your example, write foobar.x = 5?
Using ref introduces an expectancy that you can get references to variables, which I don't know if you want SilverScript to support or not.Actually I'm not supporting references/pointers in SilverScript. The only usual way to pass "references" of for example Integers is packing them to a Class, as they are always referenced, if not creating a new instance of it (cloning).
I saw that Ruby uses the $-prefix for global variables. Would you like to have the $-prefix as a synonym for global.?I don't know how often this specific feature would be used, but in general, I would tend to not offer everything in multiple variations only to make everyone happy. It may easily cause confusion, if it's not clear that there are no differences.
Should it be possible that classes have private, or even protected members?This depends on how complex you want the language to be. Should it be a simple script language for configurations and AI scripts or similar? Or do you want a full-fledged interpreted language with OOP language features?
What about virtual methods? (class inheritance is already planned)
Would you prefer the last expression of a function always being the default return value, or would you only allow explicit return values with the return keyword?What if there are multiple places to leave a function? I would prefer return statements.
What do you think about "everything is an expression"? For example, should this be possible?: x = if y > 0 then true else falseBasically an interesting idea, but can it be applied to everything? What's the expression of a loop? Of a function call that returns nothing? In this specific case, you could also use something like operator?: :P
What do you think about the idea, that any number of parameters can be passed to a function, no matter how many are specified? Non-passed parameters are initialized as nil (or their default value).You lose type safety by doing so and introduce the need to check for validity of function parameters. However, there could be a way to pass multiple parameters to functions (in an array/list or something).
When passing more parameters to a function as specified, how would you like to access the additional parameters? (compare with vargs and printf-like functions in C)As stated, a list or something similar might be the way. Do you have such a data structure which is built-in to your language?
In syntax, while-loops look like if-loops, just with a different keywords. Which other loops would you like to have (such as for), and how to design it?If-statements are no loops, they are executed at most once. The for loop should definitely be available, its design depends on other language features. Do you have something like intervals or ranges?
What do you think about the distinction between Integer and Decimal in my language? Types are dynamic, though.The distinction is a good idea, it allows to check more easily for valid index access, for example.
What should count as "false"? Only nil and false? Or also 0? What about "empty" classes and arrays?What does "count as false" mean? Inside if statements? What I wouldn't do is the ambiguity that if (xy) is true if xy is valid or true. I would allow only boolean statements in conditions, and provide something else to check for the existence or validity of a variable, maybe an additional operator like if (#xy).
Just the last expression of a function would be returned, if nothing else was explicitly returned with the return-keyword. Things like a loop could simply return nil (i.e. "no" value). This is also the default value for uninitialized variables, variables which aren't assigned to any (other) value yet.Quote from: Shy GuyWould you prefer the last expression of a function always being the default return value, or would you only allow explicit return values with the return keyword?What if there are multiple places to leave a function? I would prefer return statements.Quote from: Shy GuyWhat do you think about "everything is an expression"? For example, should this be possible?: x = if y > 0 then true else falseBasically an interesting idea, but can it be applied to everything? What's the expression of a loop? Of a function call that returns nothing? In this specific case, you could also use something like operator?: :P
Yeah, I would like to make foreach loop possible. The current "interval" data type in SilverScript is the array, but I was thinking of arrays not having a specific "size" (any index out or range simply is nil and could be assigned to any value; index mustn't be negative or a decimal number).Quote from: Shy GuyWhen passing more parameters to a function as specified, how would you like to access the additional parameters? (compare with vargs and printf-like functions in C)As stated, a list or something similar might be the way. Do you have such a data structure which is built-in to your language?Quote from: Shy GuyIn syntax, while-loops look like if-loops, just with a different keywords. Which other loops would you like to have (such as for), and how to design it?If-statements are no loops, they are executed at most once. The for loop should definitely be available, its design depends on other language features. Do you have something like intervals or ranges?
Also, a foreach loop would be very handy.
I especially mean in conditions.Quote from: Shy GuyWhat should count as "false"? Only nil and false? Or also 0? What about "empty" classes and arrays?What does "count as false" mean? Inside if statements? What I wouldn't do is the ambiguity that if (xy) is true if xy is valid or true. I would allow only boolean statements in conditions, and provide something else to check for the existence or validity of a variable, maybe an additional operator like if (#xy).
Do you differ between existence (variable has been assigned a value) and validity (variable is not nil)? If so, is it possible to "undeclare"/delete a variable, such that it becomes inexistent?
First I wanted Class and Array being two different data types. But maybe they could both be the same data type (an Object)? I mean, foo can have an attribute (foo.bar) and an index (foo[12]) at the same time.Hm, what's the use case for something that's an array and a class at the same time? I mean, wouldn't it be clearer to take a class that contains an array in such situations?
In any case, should an Array and a class always be initialized explicitely? (i.e., foo[12] or foo.bar throws an error if foo isn't an Array/Class/Object yet)I would enforce an initialization. When you don't have strict scope and lifetime rules, there may still be an old object with the same name, and one accidentally reuses it.
I think, Ranges could be a handy thing in programming, so I was thinking of implementing Ranges.Sounds like a good idea! However, I would take the .. operator for half-open intervals, as this case appears more often. Especially when your indices start at 0, you will often have intervals of the form begin..arraysize. From my own experience, the way how the STL does it is very intuitive and doesn't require off-by-one corrections (+1 or -1).
Even if I would make the brackets required, I've got problems with the special ranges [...]Why don't you take curly braces for arrays, like a = {1,2,3}?
Hm, what's the use case for something that's an array and a class at the same time? I mean, wouldn't it be clearer to take a class that contains an array in such situations?Taking a class containing an array might mean, that the user could implement an array class himself, too. And if the access works with the []-brackets, SilverScript should have some kind of operator overloading, and I have no clear plans yet how to design operator overloading methods.
Something you could also think about are maps/dictionaries. One possibility is to unify everything (array, object, map) like the tables in Lua. I have not worked a lot with them yet, so I don't know how well this works in practice. One thing you have to consider is that the more dynamic and interchangeable your types become, the more easily they are confused and type errors occur.
I would enforce an initialization. When you don't have strict scope and lifetime rules, there may still be an old object with the same name, and one accidentally reuses it.SilverScript has very local variables, similar to the principle in PHP with the functions. Variables from an outer namespace are to be accessed explicitly.
Could you show me examples / explain in detail? I have never worked with Ranges yet, I just saw that feature in Python and Ruby on the fly.I think, Ranges could be a handy thing in programming, so I was thinking of implementing Ranges.Sounds like a good idea! However, I would take the .. operator for half-open intervals, as this case appears more often. Especially when your indices start at 0, you will often have intervals of the form begin..arraysize. From my own experience, the way how the STL does it is very intuitive and doesn't require off-by-one corrections (+1 or -1).
Why don't you take curly braces for arrays, like a = {1,2,3}?I was thinking about something like that, too. But: {} for arrays and [] for ranges? Or vice-versa? And what about literal hash tables? Here is what I was thinking so far at the moment:
By the way, what tools do you use for the implementation? Just standard C++? Or a parser framework like Boost.Spirit?I'm only using the new C++11 standard, including some of its new headers and classes. I might try to make a portable version not using the new C++ as well. In addition I plan to provide a version for C, too.