Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Tenry

Pages: 1 [2] 3 4 ... 8
16
SFML projects / SilverScript: Concept of Modules
« on: October 02, 2013, 03:53:14 pm »
Like in any other programming and scripting language there shall also be the possibility in SilverScript to put the code in several files for better overview and maintenance. So I am thinking about the concept of so called modules.

Let's say, you have got your main script file main.sil, and you define a class for creating a window in window.sil.

window.sil (1):
class window
  # attributes and class methods
end


main.sil:
use window # the interpreter looks for window.sil and loads it into the "window" namespace/class
@my_window = new window.window()



Note that you can give modules, you import, any alias you want:
use window as w
@my_window = new w.window()



There are also cases, where you want to load a module directly into the current namespace. This is supported through the keyword import:
import window
@my_window = new window()



If your module only has got a single class, you can also trick there a little bit and treat the module as a class:
window.sil (2):
@window_attribute1 = 0
@window_attribute2 = 0

# ...

function new() # constructor
  # initialize a new instance
end

# more class members...



main.sil:

use window
use window as foobar

@first_window = new window()
@second_window = new foobar()




Please tell me your oppinions and suggestions about these plans. Do you have any improvements?
It is not clear yet, where the module files (when using/importing a module the first time) are searched and in which order, but they shall be searched at least in the directory where the requesting script file lies.

17
Graphics / Re: AW: Regular and bold font (2 files?)
« on: September 29, 2013, 03:42:54 pm »
SFML/freetype simply stretches the font as far as I know, thus it's more or less simulating boldness. If you want the true boldness of the given font, you'll have to load both fonts and switch in between.
For example in Photoshop you'll only get bold/italic if there's another font file, otherwise you'll have to switch to the text settings and add "artificial" boldness.
Ah, okay. Thank you very much for clarification! :)

18
Graphics / Regular and bold font (2 files?)
« on: September 29, 2013, 02:36:32 pm »
I am wondering why I have for most of my default fonts more than 1 file (for example "arial.ttf" and "arialbd.ttf"). I can see that the first one includes the default one and the second the bold one... but how does it work with SFML's setStyle() function? I mean, when loading a font, I specify only one file (propably arial.ttf), how can this become bold? It will propably don't look for a different file than, so does it a kind of to-bold conversion itself? What would happen, if I choose "arialbd.ttf" as the file and the regular style?

19
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.

20
Update

After a long break I continued the development of SilverScript. In addition, the language design got some minor and major changes:
  • Variables are not created (declared) implicitly. You always have to declare new variables with the @-character (@foobar); it can be compared with the local keyword in other languages
  • The variable's data type can't be changed implicitly (e.g., foobar[2] does not convert foobar into an array, if it isn't already one)
  • New class instances are created with the new keyword rather than by just calling its new method directly (before: inst = foobar.new(); now: inst = new foobar())
  • Class inheritance is fully supported (in theory). Base class methods and attributes can be accessed by the child class even if the child has overwritten the methods/attributes, i.e. the child class can call the base's constructor for example. Static class attributes might be possible too...
  • The VirtualMachine (interpreter) will have a garbage collector, to avoid the cyclic reference problem.
  • Function calls: parantheses (around the parameters, if available) are required, not optional.
  • Functions: parameters can have a default value or even marked as optional; additional parameters can be passed and accessed by the function, similar to C's printf() function
  • Generators are planned, so that they can be used in a foreach structur for example
The license for the first release might be LGPL, but it's propable to become zlib in a later version when SilverScript is matured.


EDIT: I forgot to show you what the C++ API is going to look like. Here a short example snippet:
#include <iostream>
#include <SilverScript.h>

using namespace std;

int main()
{
  sil::VM vm; // the virtual machine; it is initialized automatically
 
  // load a script and pack it in a callable function object
  sil::Object func = vm.loadFromFile("test.sil");
 
  // check whether script was loaded successfully
  if(!func.isNil())
  {
    sil::Object result = func.call(); // call script and get return value
    cout << "Result: " << result.toInteger() << endl;
  }
 
  return 0;
}

21
SFML website / Re: New website
« on: May 27, 2013, 07:38:17 pm »
The tutorial index is just one click away ("back" in your browser) or two ("top" + previous page in breadcrumbs).
But there are always lazy people, and I personally don't like it either if I always have to go some steps back, only, to get to the next step.

22
SFML website / Re: New website
« on: May 27, 2013, 05:42:12 pm »
I personally believe that there are many people who would like to do one tutorial after the other. Or, at least I would put links to related tutorials (i.e., what the reader could do next or should already have done when reading that tutorial).

23
SFML website / Re: New website
« on: May 01, 2013, 09:44:13 pm »
Using PHP would require to reload the page on every action, which is not an option.
I was thinking of PHP only determining the OS with the User Agent String, so that the page at least suggests the aim operating system.

24
SFML website / Re: New website
« on: May 01, 2013, 07:33:45 pm »
Not all combinations between the dropdown fields are possible, so the dialog would have to account for that.
Depending on which architecture is selected the items available for the compiler shall dynamically change.

It was just an idea. Like everything in the world this also has its pros and cons :)

25
SFML website / Re: New website
« on: May 01, 2013, 06:40:14 pm »
Ok ok. I'll think about it :P
Don't only think about it, do it! Most of the pros are already said...

Btw, I like the new design :)

Do you have any experience with server side scripting (such as PHP) or client side scripting (JavaScript)? Just an idea for the download page: it would be nice to have a default, large download button depending on the users system. Let's say, in my case there would be "Download SFML 2.0 for WINDOWS", next to it dropdowns: "Choose your architecture: [32 bit]" and "Choose your compiler: [GCC 4.7 MinGW (DW2)]". If the user doesn't find the download he's looking for or is not going to download for Windows, there can still be a section below where all the downloads (like it is at the moment) are provided. I imagine something like in the attached screenshot.


[attachment deleted by admin]

26
SFML projects / Re: About Arrays, Ranges and Objects
« on: February 18, 2013, 08:28:12 pm »
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?

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.
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.
Nonetheless I'm going to have Arrays (with indices 0, 1, 2, ...) and Maps/Hash Tables. Maps will only allow strings as keys, just to permit the use of something like an object as a key (there isn't a clear definition about object comparison behavior, 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.
SilverScript has very local variables, similar to the principle in PHP with the functions. Variables from an outer namespace are to be accessed explicitly.

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).
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.

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:
my_array = [ "First Item", "Second Item", "You may also use other types:", 27.5, [ "SubArray", ... ] ]
my_hash = [ "Name" => "John Doe", "Location" => "USA", "Age" => 22 ]
class my_object # the same as: my_object = class
  x = 0
  y = 0
end
# what about the following additional syntax for literal objects?
my_object2 = { x = 0, y = 0 }
my_range1 = [0..3]
my_range2 = [5,2] # <-- would be interpreted as an array.....

27
SFML projects / About Arrays, Ranges and Objects
« on: February 18, 2013, 06:21:07 pm »
It's me again. I got back on developing on SilverScript and my Parser (which generates the abstract syntax tree) already works very well. Now there come some more questions about the language design, and I rely on your opinions.

In SilverScript, literal Arrays are possible. Conside the following code:
foobar = ["First Element", "Second Element", ...]
# is the same as:
foobar[0] = "First Element"
foobar[1] = "Second Element"
foonar[...] = ...


Classes (you may also call them Objects at this point) are some kind of simple containers: it contains identifiers which refer to some numbers ("attributes") or some functions ("methods") and are accessed with the dot (.). Example:
# assuming foo being a class/object
foo.bar = 27


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. 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 think, Ranges could be a handy thing in programming, so I was thinking of implementing Ranges. They are useful to extract substrings or a piece of items from an array. Consider the following example:
# assuming foobar being a string or array
foobar[0] # access the first char/item
foobar[0..4] # from-to (inclusive): access the first 4 chars/items (0, 1, 2, 3, 4)
foobar[0...4] # from-to (exclusive): access the first 3 chars/items (0, 1, 2, 3)
foobar[0,4] # from-length: access the first 4 chars/items
foobar[1,] # access everything without the first char/item
foobar[,4] # access the last 4 chars/items


Instead of the pure literals to access the items (like in the example above), the user may also use identifiers:
foobar[from..to]
foobar[start,length]
foobar[my_range]

As you can see in the third line, the brackets [] shouldn't be necessary for ranges. You could write:
my_range = 1..5
Even if I would make the brackets required, I've got problems with the special ranges expressed with [start,len], [start,] and [,len], as especially the first one could also be interpreted as an array with the elements start and len, which isn't the same as a Range (yes, I want Range and Array/Object being different data types).

Do you have any ideas on the design at this points? Any opinions and suggestions are greatly welcome :)

28

Quote from: Shy Guy
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.

Quote from: Shy Guy
What do you think about "everything is an expression"? For example, should this be possible?: x = if y > 0 then true else false
Basically 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
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 Guy
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?

Quote from: Shy Guy
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?

Also, a foreach loop would be very handy.
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).

Just another note: first I wanted the array being a data type itself. If you have a variable number of items stored in it (instead of simply 2, or 17 or another static value), you have to store the size in a separate variable, as 1. the array does not really have a size visible to the programmer and 2. neither there's (yet) a "size"-operator, nor I could provide a "size"-method, because any attribute access (with the dot .) would convert the array back to an object.
But I've got a new idea: an array is not a data type itself, but instead it is just an object. Any object can have attributes/methods (which have names/identifiers), but also have, let's say, "unnamed" attributes, accessed by their indices, accessed with the []-brackets.



Quote from: Shy Guy
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).

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?
I especially mean in conditions.
Actually, there isn't yet a way to check a variable's existence (hence a variable assigned to nil, the default value, then "exists"), although the "existince" of a variable is important in another aspect of my language... a special operator for checking a variable's existince is a good idea, let me think... the hash (#) is already used for comments, but there are some other symbols left, I could use:
  • the exclamation mark (!); the logical not is expressed only by the not-keyword
  • the dollar sign ($), if not used for global variables besides "global."
  • the ampersand character (&)
  • maybe a unary *
  • or: ? : ^ ` ~

29
Hi, it's me again. There are two things to say:

1. I'm still actively working on SilverScript. I've been rewriting the parser code, so that it is more efficient and that it now generates an Abstract Syntax Tree, which wasn't there before. This makes it for example easier to optimize script code (for example calculating expressions, of constants only, to the final value on the fly).

2. There are still many things, that aren't finally decided yet. I'm developing SilverScript to be used in my personal projects, but I want to make SilverScript's source code available so that any of you could use it in their projects as well, so your suggestions on the language design might be helpful.
Note that SilverScript is designed to be embedded in games (e.g. written in C++), but I'm planning to add the feature that one could write applications based on SilverScript (runned by the main interpreter executable) and extended, for example by DLLs. Here come the questions I have to you, please tell me, what you like best:

  • SilverScript has got a global "namespace", which can be directly accessed from anywhere (classes, functions, ...) through the global namespace (e.g. global.foobar). I saw that Ruby uses the $-prefix for global variables. Would you like to have the $-prefix as a synonym for global.?
  • Should it be possible that classes have private, or even protected members?
  • 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 do you think about "everything is an expression"? For example, should this be possible?: x = if y > 0 then true else false
  • 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).
  • 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)
  • 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?
  • What do you think about the distinction between Integer and Decimal in my language? Types are dynamic, though.
  • What should count as "false"? Only nil and false? Or also 0? What about "empty" classes and arrays?
Thanks in advance in supporting me :)

30
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).

When referencing a function via the ref-keyword, I want be able to change the reference variable (that points to the original function) without affecting the original variable, and then the ref-keyword can't work for numeric variables.

Pages: 1 [2] 3 4 ... 8
anything