Re: [Gambas-user] GNU Basic?
Em Wed, 28 May 2014 17:04:09 +0200 Benoît Minisini gam...@users.sourceforge.net escreveu: I just need real help about that. Someone that just give me a list of what must be done, should be done, must not be done, should not be done to become a GNU project. And people who can do that for me! :-) I'd bet you just have to fill the questionnaire at [1] (I'm quite sure it won't exceed 10 minutes) and send it to gnueval-in...@gnu.org. Then the GNU evaluation team (of which Karl is a member) will analise it and advise you on what is further necessary to make Gambas a GNU package. Of course, Karl knows better than me. Ps: I'm very excited about the prospect of GNU Basic! \o/ :-D Footnotes: [1] http://www.gnu.org/help/evaluation -- ,= ,-_-. =. Bruno Félix Rezende Ribeiro (oitofelix) [0x28D618AF] ((_/)o o(\_)) There is no system but GNU; `-'(. .)`-' GNU Linux-Libre is one of its official kernels; \_/ All software must be free as in freedom; signature.asc Description: PGP signature -- Time is money. Stop wasting it! Get your web API in 5 minutes. www.restlet.com/download http://p.sf.net/sfu/restlet___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] A strategical move for two communities: Gambas and The GNU Project
Em Tue, 13 May 2014 23:30:05 +0200 Benoît Minisini gam...@users.sourceforge.net escreveu: Tobias has a point there. If becoming a GNU project means that the code must be rewritten to follow the GNU's C notation standard, then I can't agree. I don't have the time to do that. Not that I am against standard, but I'm like Tobias, I don't like the way GNU code is written, it's unreadable for me. If that is only a matter of time, I certainly can help you with that. On the other hand, if you don't want to write and maintain code following the GNU's C notation standard I can't say for sure whether the GNU Project would open an exception for you. However, I can ask them. After all, I'm not quite sure whether the GNU C notation is demanded or just strongly encouraged. Meanwhile, do you have other objections against the requirements found in GNU software evaluation page[1], The GNU Coding Standards[2] and Information for Maintainers of GNU software[3], so I can take the issue to their attention? Notice that you don't have to read all of [2] and [3]. Just quickly skim over it. Footnotes: [1] https://www.gnu.org/help/evaluation.html [2] https://www.gnu.org/prep/standards/html_node/index.html [3] https://www.gnu.org/prep/maintain/html_node/index.html -- ,= ,-_-. =. Bruno Félix Rezende Ribeiro (oitofelix) [0x28D618AF] ((_/)o o(\_)) There is no system but GNU; `-'(. .)`-' GNU Linux-Libre is one of its official kernels; \_/ All software must be free as in freedom; signature.asc Description: PGP signature -- Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE Instantly run your Selenium tests across 300+ browser/OS combos. Get unparalleled scalability from the best Selenium testing platform available Simple to use. Nothing to install. Get started now for free. http://p.sf.net/sfu/SauceLabs___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] A strategical move for two communities: Gambas and The GNU Project
Em Tue, 13 May 2014 23:30:05 +0200 Benoît Minisini gam...@users.sourceforge.net escreveu: If becoming a GNU project means that the code must be rewritten to follow the GNU's C notation standard, then I can't agree. I don't have the time to do that. I've contacted the GNU evaluation team about this issue and they told me that the GNU C coding style is purely optional. Therefore, there is no problem with Gambas maintaining the current coding style. The GNU Project is enthusiastic about the integration of Gambas within the GNU system as the official Basic interpreter. Although it's not an absolute requirement, the GNU Project would like you to consider relicensing Gambas' code base under GPLv3+ in order to more effectively defend Gambas users' freedom. By the way, is Gambas currently licensed under GPLv2-only or GPLv2+? Ultimately, you should fill the short questionnaire at the GNU Software Evaluation page[1] and send it to gnueval-in...@gnu.org so the GNU Project can start the formal procedure required for dubbing Gambas a GNU package. Benoît, if you have any questions or concerns don't hesitate to contact myself or the GNU evaluation team. I look forward to hearing from you. Happy joining! Footnotes: [1] http://www.gnu.org/help/evaluation.html -- ,= ,-_-. =. Bruno Félix Rezende Ribeiro (oitofelix) [0x28D618AF] ((_/)o o(\_)) There is no system but GNU; `-'(. .)`-' GNU Linux-Libre is one of its official kernels; \_/ All software must be free as in freedom; signature.asc Description: PGP signature -- Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE Instantly run your Selenium tests across 300+ browser/OS combos. Get unparalleled scalability from the best Selenium testing platform available Simple to use. Nothing to install. Get started now for free. http://p.sf.net/sfu/SauceLabs___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
[Gambas-user] A strategical move for two communities: Gambas and The GNU Project
Hello Gambas community! The GNU project[1] aims to develop the GNU system: an Unix-like operating system that is entirely free software[2]. It was launched in 1984, marking the beginning of the free software movement and has been ever since the pivotal point of philosophical, legal and technical development regarding software user's freedom. Since 1985 it is been sponsored by the FSF (Free Software Foundation)[3]: a nonprofit organization with a worldwide mission to promote computer user freedom and to defend the rights of all free software users. Technically speaking, the GNU Project is also well known by its high quality software development tools, like compilers, interpreters and debuggers, and historically has influenced the Unix-like operating systems world and industry standards. However, in its 30 years of existence, although the GNU project has developed implementations for several languages, it has not done so for the Basic language. Therefore, as a member of the GNU project I want to invite the Gambas community to join the GNU community, making Gambas a GNU package[4] and thence the official implementation of the Basic language for the GNU operating system. The GNU project will provide the full infrastructure for development and will help to spread awareness of Gambas, promoting it as the de facto GNU Basic language implementation. As a GNU package, Gambas can benefit from FSF endorsement, and potentially fund raising campaigns and sponsoring. I commit myself to help wherever needed: with the forge migration from Sourceforge to GNU Savannah; with the compliance to the GNU Coding and Maintenance Standards, etc. What are your thoughts on that? Footnotes: [1] https://gnu.org/ [2] https://gnu.org/philosophy/free-sw.html [3] https://www.fsf.org/ [4] https://www.gnu.org/help/evaluation.html -- ,= ,-_-. =. Bruno Félix Rezende Ribeiro (oitofelix) [0x28D618AF] ((_/)o o(\_)) There is no system but GNU; `-'(. .)`-' GNU Linux-Libre is one of its official kernels; \_/ All software must be free as in freedom; signature.asc Description: PGP signature -- Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE Instantly run your Selenium tests across 300+ browser/OS combos. Get unparalleled scalability from the best Selenium testing platform available Simple to use. Nothing to install. Get started now for free. http://p.sf.net/sfu/SauceLabs___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] A strategical move for two communities: Gambas and The GNU Project
It's also worth to add that Gambas being part of GNU will ease the adoption of programs written in Gambas by the GNU project and then further increase the visibility of Gambas language and its interpreter. My other two cents ;-) -- ,= ,-_-. =. Bruno Félix Rezende Ribeiro (oitofelix) [0x28D618AF] ((_/)o o(\_)) There is no system but GNU; `-'(. .)`-' GNU Linux-Libre is one of its official kernels; \_/ All software must be free as in freedom; signature.asc Description: PGP signature -- Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE Instantly run your Selenium tests across 300+ browser/OS combos. Get unparalleled scalability from the best Selenium testing platform available Simple to use. Nothing to install. Get started now for free. http://p.sf.net/sfu/SauceLabs___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] Wrapping methods which accept optional arguments
Em Thu, 08 May 2014 17:12:04 +0200 Benoît Minisini gam...@users.sourceforge.net escreveu: In revision #6258, I implemented a new special function, IsMissing(), that returns if an optional argument is missing. That's awesome! At this pace very soon Gambas will become the greatest programming language ever. ;-) I didn't tested it with functions taking a variable number of arguments yet. I've tested it, and all seems to be fine. Thank you very much! Happy hacking! -- ,= ,-_-. =. Bruno Félix Rezende Ribeiro (oitofelix) [0x28D618AF] ((_/)o o(\_)) There is no system but GNU; `-'(. .)`-' GNU Linux-Libre is one of its official kernels; \_/ All software must be free as in freedom; signature.asc Description: PGP signature -- Is your legacy SCM system holding you back? Join Perforce May 7 to find out: #149; 3 signs your SCM is hindering your productivity #149; Requirements for releasing software faster #149; Expert tips and advice for migrating your SCM now http://p.sf.net/sfu/perforce___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] Calling external function by pointer
Em Wed, 07 May 2014 21:36:04 +0200 Benoît Minisini gam...@users.sourceforge.net escreveu: Le 07/05/2014 20:43, Bruno Félix Rezende Ribeiro a écrit : Em Wed, 07 May 2014 19:32:46 +0200 Benoît Minisini gam...@users.sourceforge.net escreveu: I'm afraid this is not possible, because the FFI library used by Gambas must know the signature of the function before calling it. What about providing a way to declare the function signature for a pointer variable? Why do you need that? For example, the Xlib function 'XSetErrorHandler' accepts the new error handler as an argument and returns the old one. I have a class called 'X11Error' which interfaces with the Xlib's error facilities. Inside its '_new' method it registers within Xlib its private method 'ErrorHandler' as the error handler and stores the returned pointer to the default Xlib's error handler inside a private variable. Then, to define a new error handler the user has to create a new object of class 'X11Error' and then catch the event 'Error' which will be raised by 'ErrorHandler'. However, if there is no observer for such object the Xlib's default error handler is called instead. Therefore I need the ability to call an anonymous function whose signature is known. Do you know any other way? Even if there is a specific way to solve this very problem within Xlib, I think Gambas module programmers would benefit of such improvement. -- ,= ,-_-. =. Bruno Félix Rezende Ribeiro (oitofelix) [0x28D618AF] ((_/)o o(\_)) There is no system but GNU; `-'(. .)`-' GNU Linux-Libre is one of its official kernels; \_/ All software must be free as in freedom; signature.asc Description: PGP signature -- Is your legacy SCM system holding you back? Join Perforce May 7 to find out: #149; 3 signs your SCM is hindering your productivity #149; Requirements for releasing software faster #149; Expert tips and advice for migrating your SCM now http://p.sf.net/sfu/perforce___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] Feature request: Make 'Pointer' a true integer type
Em Thu, 08 May 2014 14:25:33 +0200 Benoît Minisini gam...@users.sourceforge.net escreveu: Pointer are already automatically converted to integers or longs. What do you need to do exactly? This problem arose when I tried to use some bit manipulation functions over pointers and get caught by an error. The very simple code below show what I mean: Dim pPointer As Pointer = BSet(pPointer, 2) The evaluation of the previous line raises an error which says: Type mismatch: wanted Number, got Pointer instead However I can obtain the desired behavior by rewriting it as: Dim pPointer As Pointer = BSet(CLong(pPointer), 2) My request is to make the interpreter operate directly over pointers within numeric functions or to convert Pointers to Longs transparently whenever needed. Considering the error message, I think the interpreter should consider the type 'Pointer' a Number type also. Thank you for your dedication. Ps: I'm using Gambas 3.5.2. -- ,= ,-_-. =. Bruno Félix Rezende Ribeiro (oitofelix) [0x28D618AF] ((_/)o o(\_)) There is no system but GNU; `-'(. .)`-' GNU Linux-Libre is one of its official kernels; \_/ All software must be free as in freedom; signature.asc Description: PGP signature -- Is your legacy SCM system holding you back? Join Perforce May 7 to find out: #149; 3 signs your SCM is hindering your productivity #149; Requirements for releasing software faster #149; Expert tips and advice for migrating your SCM now http://p.sf.net/sfu/perforce___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] Calling external function by pointer
Em Thu, 8 May 2014 18:41:13 +0200 Tobias Boege tabo...@gmail.com escreveu: I understand if you want to be able to do all the things in pure Gambas but for that, new syntaxes must be created and I can't imagine how those could fit into the existing Basic language elements... That's the whole point of this. I'm creating a component entirely written in Gambas which interfaces with a complex C library. This is a unique opportunity to discover weaknesses in Gambas language in this particular domain. Personally I'd like to make Gambas as simple and powerful as possible. I'd like to see Gambas as a standalone language in the sense that everything one could possibly want to implement with it could be done using only plain Gambas, at least in principle. I have to respectfully disagree with you, because I can clearly see how the improvements can nicely fit together within the Basic language. We are already plenty of facilities to interface with external C libraries, why not just add a few more to make Gambas components independent of the C language? If we had reasoned by the principle you just claimed, why on earth would Gambas support external function declarations, for example? Does that actually fit better within Basic than my, usually small, proposed improvements? What's the logic behind providing several and the main facilities to interface to external libraries and omitting a handful useful ones which would otherwise make the language functionally complete? In my view, while programming components, we should only resort to C(++) language for speed, not functionality. A lack of useful functionality in a language is not the programmer's language choice fault but a flaw in the very language. To interface with C libraries, it's IMHO still best to write C components or at least small C cores and build a complete component in Gambas on top of them. That's because we are compelled to work around Gambas limitations that should not exist in the first place. Regards. -- ,= ,-_-. =. Bruno Félix Rezende Ribeiro (oitofelix) [0x28D618AF] ((_/)o o(\_)) There is no system but GNU; `-'(. .)`-' GNU Linux-Libre is one of its official kernels; \_/ All software must be free as in freedom; signature.asc Description: PGP signature -- Is your legacy SCM system holding you back? Join Perforce May 7 to find out: #149; 3 signs your SCM is hindering your productivity #149; Requirements for releasing software faster #149; Expert tips and advice for migrating your SCM now http://p.sf.net/sfu/perforce___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] New syntax for using variables arguments in a function call
Em Tue, 06 May 2014 09:51:00 +0200 Benoît Minisini gam...@users.sourceforge.net escreveu: In revision #6252, I added the following syntax: [...] Thank you! That is a very useful feature. Happy Hacking! -- ,= ,-_-. =. Bruno Félix Rezende Ribeiro (oitofelix) [0x28D618AF] ((_/)o o(\_)) There is no system but GNU; `-'(. .)`-' GNU Linux-Libre is one of its official kernels; \_/ All software must be free as in freedom; signature.asc Description: PGP signature -- Is your legacy SCM system holding you back? Join Perforce May 7 to find out: #149; 3 signs your SCM is hindering your productivity #149; Requirements for releasing software faster #149; Expert tips and advice for migrating your SCM now http://p.sf.net/sfu/perforce___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
[Gambas-user] Calling external function by pointer
Hello all! Suppose we have an external function pointer inside the Gambas variable 'pExternFunction' and we want to call the correspondent function passing the arguments, known at compilation time, 'Arg1' to 'ArgN'. How can we accomplish this in Gambas? Thanks in advance. -- ,= ,-_-. =. Bruno Félix Rezende Ribeiro (oitofelix) [0x28D618AF] ((_/)o o(\_)) There is no system but GNU; `-'(. .)`-' GNU Linux-Libre is one of its official kernels; \_/ All software must be free as in freedom; signature.asc Description: PGP signature -- Is your legacy SCM system holding you back? Join Perforce May 7 to find out: #149; 3 signs your SCM is hindering your productivity #149; Requirements for releasing software faster #149; Expert tips and advice for migrating your SCM now http://p.sf.net/sfu/perforce___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] Calling external function by pointer
Em Wed, 07 May 2014 19:32:46 +0200 Benoît Minisini gam...@users.sourceforge.net escreveu: I'm afraid this is not possible, because the FFI library used by Gambas must know the signature of the function before calling it. What about providing a way to declare the function signature for a pointer variable? -- ,= ,-_-. =. Bruno Félix Rezende Ribeiro (oitofelix) [0x28D618AF] ((_/)o o(\_)) There is no system but GNU; `-'(. .)`-' GNU Linux-Libre is one of its official kernels; \_/ All software must be free as in freedom; signature.asc Description: PGP signature -- Is your legacy SCM system holding you back? Join Perforce May 7 to find out: #149; 3 signs your SCM is hindering your productivity #149; Requirements for releasing software faster #149; Expert tips and advice for migrating your SCM now http://p.sf.net/sfu/perforce___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
[Gambas-user] Feature request: Make 'Pointer' a true integer type
Hello again! It'd be very handy if 'Pointer' was considered by the interpreter as an integer data type like 'Byte', 'Short', 'Integer' and 'Long'. That way one could use any integer function indiscriminately on a Pointer as well, rather than converting it to 'Long' (using 'CLong' function) every time it's an argument for an integer function. That is specially relevant when interfacing with external C libraries, where to make portable Gambas programs one need to treat the C data type 'long' as the Gambas data type 'Pointer'. This means that 'Pointer' isn't meaningful only in pointer contexts but also in ordinary integer contexts. What do you think about this proposed change? Is there any way in which it can be harmful to existing code or interpreter's functionality? Thanks in advance. Ps: In order to make portable Gambas programs which interface with external C libraries, one needs to follow the correct equivalence between C and Gambas integer data types, which is given by the table: [C] [Gambas] charByte short Short int Integer longPointer void * Pointer long long Long However, the Gambas Wiki page [1], besides having an incomplete table which does not address 'char', 'short' and 'long long', says that the equivalent of C's 'long' is Gambas' 'Long', what is only true on some 64-bit architectures. Footnotes: [1] http://gambaswiki.org/wiki/howto/extern -- ,= ,-_-. =. Bruno Félix Rezende Ribeiro (oitofelix) [0x28D618AF] ((_/)o o(\_)) There is no system but GNU; `-'(. .)`-' GNU Linux-Libre is one of its official kernels; \_/ All software must be free as in freedom; signature.asc Description: PGP signature -- Start Your Social Network Today - Download eXo Platform Build your Enterprise Intranet with eXo Platform Software Java Based Open Source Intranet - Social, Extensible, Cloud Ready Get Started Now And Turn Your Intranet Into A Collaboration Platform http://p.sf.net/sfu/ExoPlatform___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] Feature request: absolute C data type equivalents and native type aliasing
Em Sat, 26 Apr 2014 13:06:27 +0200 Benoît Minisini gam...@users.sourceforge.net escreveu: I don't want to discourage you, but I think XLib will not be used anymore in a few years because of Wayland. :-/ Well, we can't be sure whether Xlib will fall into desuse. And even if that does happen I'll write a Wayland Gambas component when the time has come, and that's not now. ;-) Anyway, Xlib programs will still be runnable in Wayland environments for the foreseeable future by some compatibility layer. Also, at the unlikely worst possible case, maybe it's worth to write a component that will still be useful for a few years from now. Would you accept, in the main Gambas' distribution, a well written and documented Xlib component? Use the Pointer datatype each time you see a long. It has the same behaviour. I'd like to avoid such ugly hacks, but I guess I haven't many options. :-( I can't add any native datatype to Gambas at the moment. You must wait for something like Gambas 4. :-) How long do I have to wait? :-P How can I help you? Thank you for your time. -- ,= ,-_-. =. Bruno Félix Rezende Ribeiro (oitofelix) [0x28D618AF] ((_/)o o(\_)) There is no system but GNU; `-'(. .)`-' GNU Linux-Libre is one of its official kernels; \_/ All software must be free as in freedom; signature.asc Description: PGP signature -- Start Your Social Network Today - Download eXo Platform Build your Enterprise Intranet with eXo Platform Software Java Based Open Source Intranet - Social, Extensible, Cloud Ready Get Started Now And Turn Your Intranet Into A Collaboration Platform http://p.sf.net/sfu/ExoPlatform___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
[Gambas-user] Feature request: absolute C data type equivalents and native type aliasing
Hello Gambas users and developers! I'm working on a module for Gambas, fully written in Gambas language, which aims to provide full access to the X Window System's Xlib library through a high-level Gambas-ish interface. I'm in the very beginning, but I've been making progress and so far I've implemented 9% of the features of the C language X interface as described in [1]. However, I'm facing a major problem that needs to be addressed before I get too far. Let's take a look at a particular instance of it. Various Xlib functions accept or return a C 'long' data-type parameter. GCC reports that on my x86 machine 'long' is 4 bytes wide while on my x86_64 machine it's 8 bytes wide instead. AFAIK, Gambas 'Integer' and 'Long' data-type are always 4 and 8 bytes wide, respectively, regardless of architecture. How can I cope with that when declaring external functions and structures? The only solution I could think of is to use Gambas' preprocessor directives, but it isn't practical to put a preprocessor conditional again and again every time I'm declaring something which uses the same C language type: I'd have to do that several hundreds of times! So, I'd suggest to provide absolute C data type equivalents to 'char', 'short', 'int', 'long', 'long long', 'float', 'double' and 'long double', so we could interface smoothly with C libraries and write robust and easy to maintain components for Gambas, entirely in Gambas language. In this case the C compiler would decide what's the wideness of each data type at Gambas' compilation time. One suggestion for their names is: CChar, CShort, CInt, CLong, CLongLong, CFloat, CDouble and CLongDouble. This feature alone would be a great improvement, but not enough. Within C libraries it's a common practice to define conditionally new data types in terms of the native ones. In order to have a complete environment to interface with external libraries inside Gambas, we also need a way to make aliases to native Gambas' data types conditionally. It could well be a preprocessor facility, but that isn't required at all. I'd suggest something that looks like: #If ARCH = x86 # AliasType(CLong, XID) #Else # AliasType(CInt, XID) #Endif #AliasType(XID, WindowID) #AliasType(XID, FontID) Thanks in advance. Footnotes: [1] http://www.x.org/releases/X11R7.7/doc/libX11/libX11/libX11.html [2] Like 'Window', 'Font', 'Pixmap', 'Colormap', 'Cursor' and 'GContext'. -- ,= ,-_-. =. Bruno Félix Rezende Ribeiro (oitofelix) [0x28D618AF] ((_/)o o(\_)) There is no system but GNU; `-'(. .)`-' GNU Linux-Libre is one of its official kernels; \_/ All software must be free as in freedom; signature.asc Description: PGP signature -- Start Your Social Network Today - Download eXo Platform Build your Enterprise Intranet with eXo Platform Software Java Based Open Source Intranet - Social, Extensible, Cloud Ready Get Started Now And Turn Your Intranet Into A Collaboration Platform http://p.sf.net/sfu/ExoPlatform___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] Inheriting, wrapping and casting
Em Thu, 24 Apr 2014 22:57:45 +0200 Benoît Minisini gam...@users.sourceforge.net escreveu: I fixed your patch, as it didn't work when using the Object datatype. You get it in revision #6249. Thank you very much, Benoît! -- ,= ,-_-. =. Bruno Félix Rezende Ribeiro (oitofelix) [0x28D618AF] ((_/)o o(\_)) There is no system but GNU; `-'(. .)`-' GNU Linux-Libre is one of its official kernels; \_/ All software must be free as in freedom; signature.asc Description: PGP signature -- Start Your Social Network Today - Download eXo Platform Build your Enterprise Intranet with eXo Platform Software Java Based Open Source Intranet - Social, Extensible, Cloud Ready Get Started Now And Turn Your Intranet Into A Collaboration Platform http://p.sf.net/sfu/ExoPlatform___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] Inheriting, wrapping and casting
Em Sat, 19 Apr 2014 01:07:21 +0200 Tobias Boege tabo...@gmail.com escreveu: Oh, I forgot to ask: do you want the patch that allows inheritance- compatible[*] classes to be used in place of a class in method and property signatures to test the above approach - even if it's unlikely that it goes mainline? Sure! Reading [1] and [2], it seems that the main technical reason Gambas doesn't support overriding signatures within inherited classes is an optimization. IMHO, the only way to justify such a restriction on functionality is if the table symbol lookup were impracticably slow. I'm usually much more concerned about powerfulness than speed. I think one language like Gambas should have its generality and expressiveness maximized to the extent that its execution speed stays reasonable. I really like the freedom of choosing how to structure my code. The idea that the interpreter is passive about my natural and intuitive programming creative process, as long it's still logically consistent, is priceless. Paraphrasing The GNU Coding Standards[3]: The interpreter should be your servant, not your master. Thank you very much for your efforts coding on the interpreter. Footnotes: [1] http://sourceforge.net/p/gambas/mailman/message/30783547/ [2] http://code.google.com/p/gambas/issues/detail?id=78 [3] http://www.gnu.org/prep/standards/html_node/index.html -- ,= ,-_-. =. Bruno Félix Rezende Ribeiro (oitofelix) [0x28D618AF] ((_/)o o(\_)) There is no system but GNU; `-'(. .)`-' GNU Linux-Libre is one of its official kernels; \_/ All software must be free as in freedom; signature.asc Description: PGP signature -- Learn Graph Databases - Download FREE O'Reilly Book Graph Databases is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/NeoTech___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
[Gambas-user] Inheriting, wrapping and casting
Hello Gambas fellows! Suppose we are overriding the class 'Variant[]' to add the event 'Update' which will be raised after the completion of any method which could possibly modify the array structure. In particular, we need to override appropriately any function that happens to do so. For exposition purposes let's consider the 'Extract' function, which removes one or more elements from the array and returns them. It's signature is as follow: Public Function Extract(iStart As Integer, \ Optional iLength As Integer) As Variant[] Our inherited class has, hence, to override this function with another of the exact same signature, by Gambas' rules. However, it doesn't make sense to return an object of the base class, while the operation is executed by a derived class over an object thereof. It seems there is no easy or natural way around it. We could declare a second extraction function for the derived class named after a different symbol like ExtractDerived, but we'd break the interface, what isn't a desired outcome. Another approach would be to forget this particular base class and go upwards until there is no possible conflicting functions and to inherit from there, what happens to be in this case the immediate base class of 'Variant[]' called Array. However, we'd have to re-implement large portions of the 'Variant[]' class, that could otherwise be immediately deployed if not by our particular design problem at hand. One last, and arguably more reasonable, approach is to give up the syntactical native language's feature of inheritance --- and its useful properties -- and to define a dedicated container base class, which inherits from nowhere, semantically wrapping all functionality of the class 'Variant[]'. It'd work as a layer for accessing the underlying variant array which would be stored in a private variable and isolated from the outside world, i.e., not directly accessible by any property. The only way to modify the array's content would be to use the class' interface which would mimic that of 'Variant[]'. As we've seen, there is no way if not by modifications of the interpreter's very core. Thus, I'd like to know why Gambas enforces the signature of functions onwards inherited classes. If not by technical reasons, but only for methodological consistency requirements, I'd like to suggest that we make it, at least, allows to use the inherited class in place of the parent class within method signatures. Personally, I'd find yet more useful if there were no restriction at all. A very interesting and useful feature, related but independent of this suggestion, is that the interpreter could take care of casting objects in both directions in an hierarchy of classes. In order to accomplish it, there would be introduced two special methods which would be implemented in any class the programmer deems them meaningful and useful: '_castUp' and '_castDown', for casting an object from the inherited to the parent class, and from the parent to the inherited class, respectively. Being 'ThisClass' the inherited class and 'UpClass' its parent, the special methods signatures would be: Static Public Function _castUp (hThisClass As ThisClass) As UpClass Static Public Function _castDown (hUpClass As UpClass) As ThisClass The job of the interpreter would be to call these functions, in a possible chain, to cast automatically upside or downside every time an object of certain class is used in a context that requires an object of another class but in the same hierarchy. What are your thoughts on that? Thank you. -- ,= ,-_-. =. Bruno Félix Rezende Ribeiro (oitofelix) [0x28D618AF] ((_/)o o(\_)) There is no system but GNU; `-'(. .)`-' GNU Linux-Libre is one of its official kernels; \_/ All software must be free as in freedom; signature.asc Description: PGP signature -- Learn Graph Databases - Download FREE O'Reilly Book Graph Databases is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/NeoTech___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] Inheriting, wrapping and casting
Em Thu, 17 Apr 2014 21:13:41 +0200 Fabien Bodard gambas...@gmail.com escreveu: Well ... I'm surely not good as you are but I didn't understand the meanning of castup or down... What is it for ? Let me give you an abstract example. Suppose we have the class 'SuperClass' which implements the function 'Frobnicate' that has the following signature: Static Public Function Frobnicate(hSuperClass As SuperClass) \ As SuperClass Suppose now that we've extended our original class, and thus derived the class 'SubClass', and let 'hSubClass' be any object thereof. Suppose the function 'Frobnicate' was not overridden and that 'SuperClass.Frobnicate(hSubClass)' is generally not that useful because the implicit identity casting doesn't generate a very meaningful 'SuperClass' object for the problem at hand. However, we have a much more interesting idea than the interpreter of how to map 'SubClass' objects to meaningful and useful 'SuperClass' objects. Here the proposed special method '_castUp' comes in hand. We add it to the code of 'SubClass' in order to do the desired up-cast automatically: Static Public Function _castUp(hSubClass As SubClass) As SuperClass ' Do a magical conversion using arbitrary processing in accordance ' with our idea of a canonical map from 'SubClass' to 'SuperClass'. End Now when the interpreter evaluates the expression 'SuperClass.Frobnicate(hSubClass)' it'll notice there is an up-cast method and then it'll give this precedence over the implicit identity casting. Now we have a meaningful object to work with! The '_castDown' special method works analogously but the other way around. The only major difference is that the interpreter doesn't have a standard implicit identity cast in this direction and therefore raises an error when one tries to use a 'SuperClass' object in a 'SubClass' context. The main point to emphasize here is that we are interested in non-trivial castings. Therefore, we need it both directions and identity casts (the copy of common properties) doesn't suffice. Hope it helps. Happy Hacking! -- ,= ,-_-. =. Bruno Félix Rezende Ribeiro (oitofelix) [0x28D618AF] ((_/)o o(\_)) There is no system but GNU; `-'(. .)`-' GNU Linux-Libre is one of its official kernels; \_/ All software must be free as in freedom; signature.asc Description: PGP signature -- Learn Graph Databases - Download FREE O'Reilly Book Graph Databases is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/NeoTech___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] Advising methods of non-fixed argument tuple in a parent class
of having classes with brackets in their names is useful --- and even the interpreter is fine with that --- I don't see why this wouldn't be an IDE bug. Have you or anyone else addressed this bug or submitted a bug report on this? That way, you are overriding the Variant[] class in the interpreter's global symbol table, using inheritance, i.e. you extend it. You can add features to Variant[] which are immediately available to all users of the Variant[] class without having to change any code. That's explained in the docs as well[1]. Talking about that, don't you think that an 'Update' event as I've described would be a very nice core addition to the 'Array' class in the main distribution? It seems to me it would be generally useful for users. Poor 'Array' class... it doesn't have any events --- let's give it some useful ones. ;-) I really appreciate your very interesting response. Happy Hacking! Footnotes: [1] http://gambaswiki.org/wiki/doc/forum -- ,= ,-_-. =. Bruno Félix Rezende Ribeiro (oitofelix) [0x28D618AF] ((_/)o o(\_)) There is no system but GNU; `-'(. .)`-' GNU Linux-Libre is one of its official kernels; \_/ All software must be free as in freedom; signature.asc Description: PGP signature -- Learn Graph Databases - Download FREE O'Reilly Book Graph Databases is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/NeoTech___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
[Gambas-user] Wrapping methods which accept optional arguments
Hello Again! Suppose we are overriding the class 'Array' to add the event 'Update' which will be raised after the completion of any method which could possibly modify the array structure. We start by the 'Remove' method which has the following signature: Public Sub Remove(iIndex As Integer, Optional iLength As Integer) As our override method is not much more than a wrapper around the parent's method, it needs to call 'Super.Remove' method with the same arguments it has received in the first place. Consider our first attempt to do just that, which would be: Super.Remove(iIndex, iLength) However, that call won't work as expected because although 'iLength' is received as an optional argument, it's invariably passed along to the parent's method, be it originally given or not, in which case it would default to '0'. In order to solve that problem we may consider to discriminate semantically the optional argument, if that is at all possible. To discover if that is actually the case, we must prove that either one of the following properties must hold about the semantics of the method for some possible default value of the optional argument: 1. The method's semantics is defined for the default value of the optional argument, but would be indistinguishable if the optional argument were otherwise omitted. 2. The method's semantics is undefined for the default value of the optional argument. It turns out in this particular case the 'Remove' method satisfies both properties. For the first property we can just take 'iLength' as '1', since the default behavior (when iLength is omitted) is to remove just one element of the array. Then, our method would look like: Public Sub Remove(iIndex As Integer, Optional iLength As Integer = 1) Super.Remove(iIndex, iLength) Raise Update() End For the second property we could take 'iLength' as '0' because there is no a-priori nor auto-evident distinction between removing zero elements of an array and not executing the procedure of removal at all. Therefore we can be assured that no one would expect a meaningful behavior from a non-meaningful argument and then reserve that for internal use, promoting the semantics of the method as undefined/unpredictable for that particular optional argument's default value. Our override method would be: Public Sub Remove(iIndex As Integer, Optional iLength As Integer = 0) If iLength = 0 Then Super.Remove(iIndex) Else Super.Remove(iIndex, iLength) EndIf Raise Update() End Notice that this latter method's form could be used to obtain a method functionally indistinguishable from the former method's form by just replacing the zeros by ones. Nevertheless, the converse is not true. Although, we could successfully solve the problem for this particular instance of the problem resorting to semantical analysis, it does not help much with other methods which have an entire different semantics whose analysis must always be done in a case-by-case basis. Even worse, it's possible to prove the following statement: There is a primitive method, which accepts optional arguments, that can't be perfectly wrapped by any non-primitive method of the same signature if, and only if, there is a way for primitive methods to unambiguously check whether a particular optional argument was supplied and there is no way of doing so for non-primitive methods. Where 'primitive method' is defined as a method not written in Gambas which is callable from at least one method written in Gambas; and 'non-primitive method' is defined as a method written in Gambas. Furthermore we admit the premise that it's impossible for a non-primitive method to call another method referencing the unchanged original argument tuple. The theorem makes explicit our necessity of providing a way of checking unambiguously, in Gambas code, whether any given optional argument were actually supplied or, alternatively, preventing primitive methods of doing so. Otherwise, there will be methods for which it is impossible to remedy the situation of perfect-wrapping by pure semantic analysis. Now for a more pragmatic approach, it'd be very useful to document the default value of optional arguments as part of the method's signature for all primitive and non-primitive methods where it is applicable. Those methods can always be perfectly wrapped using the first property of the semantical analysis given above. Moreover there is a trivial algorithm to do so, granted we know the default values of every optional argument. That way we eliminate the step of semantical analysis even without modification to the interpreter's code. My questions are: do you see any problem with the reasoning outlined above? Have you ever faced the same problem? Do you know some workaround? How do you think Gambas may be improved to solve this problem? Thank you. -- ,= ,-_-. =. Bruno Félix Rezende Ribeiro (oitofelix) [0x28D618AF] ((_/)o o
Re: [Gambas-user] Possible bug extending array class of non-native classes [Was: Advising methods of non-fixed argument tuple in a parent class]
Em Tue, 15 Apr 2014 12:55:51 +0200 Tobias Boege tabo...@gmail.com escreveu: And finally let me tell you something about extending classes: it gets especially cool when you call your extending class like the extended class. Above, you would not call your class VariantArray but Variant[]. [ At present, you have to create .src/Variant[].class outside of the IDE in your project because the IDE forbids use of brackets in class names. However, the interpreter doesn't seem to have any problems with that. ] That way, you are overriding the Variant[] class in the interpreter's global symbol table, using inheritance, i.e. you extend it. You can add features to Variant[] which are immediately available to all users of the Variant[] class without having to change any code. That's explained in the docs as well[1]. Strangely this extension trick doesn't work with an array of a non-native class. The interpreter doesn't complain, but no events or methods defined in the extended class are raised or called. Could you please confirm this? Do you think this is a bug? If not, do you have an explanation for this strange behavior? -- ,= ,-_-. =. Bruno Félix Rezende Ribeiro (oitofelix) [0x28D618AF] ((_/)o o(\_)) There is no system but GNU; `-'(. .)`-' GNU Linux-Libre is one of its official kernels; \_/ All software must be free as in freedom; signature.asc Description: PGP signature -- Learn Graph Databases - Download FREE O'Reilly Book Graph Databases is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/NeoTech___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
[Gambas-user] Advising methods of non-fixed argument tuple in a parent class
Hello all! Suppose we want an array of variants which has the nice property of raising an event after any modification, like addition or removal of elements, has occurred to itself. Since the class 'Variant[]' does not have this specific capability but, on the order hand, has every other desired array handling functionality we need, we'll make good use of the OOP philosophy of re-usability and extend it to add our desired functionality. Our extended class will be called 'VariantArray' and will have an event called Update that will be raised after any modification procedure has taken place. Therefore, in its header we so declare: Inherits Variant[] Event Update() We now need to advise[1] the parent's methods intended for modification of the array structure. The idea is rather simple: we supplement a parent's method definition by simply raising the 'Update' event after its completion. Let's use the special method '_put' as our example case. This method allows instances of our class to be used as arrays in assignments. In a hypothetical N-dimensional array we'd have the following signature: Public Sub _put(vVariant As Variant, iIndex1 As Integer, ..., iIndexN As Integer) Where '...' is a meta-syntactical symbol which represents the full list of indexes parameters varying from 2 to N-1. Thus the override function would be: Public Sub _put(vVariant As Variant, iIndex1 As Integer, ..., iIndexN As Integer) Super._put(vVariant, iIndex1, ..., iIndexN) Raise Update() End For an array of non-fixed size we'd have the following signature: Public Sub _put(vVariant As Variant, iIndex1 As Integer, ...) Where the syntactical symbol '...' means the method can take extra arguments. As the result of the definition of an arbitrary argument tuple there is no way the previous syntax for calling the parent's method definition could possibly work, i.e., in the expression Super._put(vVariant, iIndex1, ...) there is no string of syntactical symbols one could replace the meta-syntactical symbol '...' in order to make the parent's '_put' method receive the same argument tuple of the child '_put' method. The only hope to solve this problem is to use the static class 'Param' to access the extra arguments in the form of an array. However, we can't use an ordinary function call to accomplish what we want, because it won't accept an array as a meta-argument. Fortunately that's what the method 'Call' of the 'Object' class provides us. Therefore, being 'PARENT' the meta-syntactical variable whose hypothetical syntactic expression points to the parent's method implementations, we'd use: Object.Call(PARENT, _put, [vVariant, iIndex1].Insert(Param.All)) Even so, there is no expression one could fit in 'PARENT' that would make the call work as intended. In the previous case of an arbitrary but defined number of arguments we used the 'Super' keyword to reference the parent's method implementation. This worked there because it was a direct and imediate use, and would not work here in place of 'PARENT'. So we are stuck, because to reference the parent's method implementation we need to use a syntax which doesn't allow the use of a non-fixed tuple of arguments, and in order to use a non-fixed tuple of arguments we have to give up our ability of referencing the parent's method implementation. The conclusion is quite clear: it can't be done. My questions are: is there any error with the reasoning given above? If not, is there a workaround? If not, how could we improve Gambas to solve this problem? Irrespective to all of this, do you suggest another approach to accomplish the initial objective of obtaining an array which raises events when modified? What about the general idea of advising methods of an inherited class? In general, how can we make it work? Thank you for your attention. I look forward to your answer. Footnotes: [1] I've borrowed the term advice from the GNU Emacs terminology for a very similar concept. Here is what its manual says about it: The advice feature lets you add to the existing definition of a function, by advising the function. This is a cleaner method for a library to customize functions defined within Emacs--cleaner than redefining the whole function. -- ,= ,-_-. =. Bruno Félix Rezende Ribeiro (oitofelix) [0x28D618AF] ((_/)o o(\_)) There is no system but GNU; `-'(. .)`-' GNU Linux-Libre is one of its official kernels; \_/ All software must be free as in freedom; signature.asc Description: PGP signature -- Learn Graph Databases - Download FREE O'Reilly Book Graph Databases is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/NeoTech___ Gambas-user
Re: [Gambas-user] Interpreter's treatment of classes
Em Sat, 12 Apr 2014 17:38:03 +0200 Benoît Minisini gam...@users.sourceforge.net escreveu: All that is because, is a has two meanings in Gambas. 1) An object reference A is a class B. It means that the class of the object A is the class B. 2) An expression is a datatype. And there are two datatypes, gb.Object and gb.Class. gb.Object is any expression that returns a non-null object reference. An object reference internally includes two pointers: a class pointer, and an object data pointer. gb.Class is any expression that returns a class. It includes one pointer, the class pointer. gb.Class exists only for internal optimization reasons. I could have used instead a gb.Object, with a null object data pointer. But it would have been slower. Now, as stated in the wiki, classes are really objects whose class is the Class class. But a reference to a class as an object is not the same thing as a reference to the class. The first one has methods that describe the class structure, the second one allows to call the static methods of the class. I think I can see what you mean here. But I can't quite understand how have you reached the conclusion that classes are really objects whose class is the 'Class' class? What is the criteria classes are satisfying that 1) Makes them objects. 2) Granted (1), makes them instances of the class Class. Are the answers to these two questions consistent with the Gambas' meaning of object, class and instance? Or is that just a particular exception to the general rule? Do you see any problem with the perhaps more intuitive and consistent approach of making 'Class' a primitive type as explained in the model below? ** Reformulation of the interpreter's behavior regarding classes ** The declaration Dim hClass As Class = MMain would make 'hClass' point to the same class that 'MMain' points to so that TypeOf(MMain) == gb.Class TypeOf(hClass) == gb.Class If(hClass = MMain, Equal, Not Equal) == Equal MMain Is Class == [Error: Unexpected Class] hClass Is Class == [Error: Unexpected Class] The errors are the same current raised by the expression MMain Is Integer == [Error: Expected Integer] This is consistent because like the type 'Integer', the type 'Class' would be not a class, and therefore would not make sense as the right-hand side operand of the 'Is' operator which is intended to check instantiation regarding inheritance, which is clearly not applicable to classes in the reformulated model. On the other hand to obtain the introspection capabilities the declaration Dim hClassIntrospection As ClassInstropection = MMain would make 'hClassIntrospection' points to the object which describes the class 'MMain' so that TypeOf(hClassIntrospection) == gb.Object hClassIntrospection Is ClassIntrospection == True MMain Is ClassIntrospection == False hClass Is ClassIntrospection == False hClassIntrospection.Name == MMain If(hClassIntrospection = MMain, Equal, Not Equal) == [Error: Type mismatch: wanted Object, got Class Instead] If(hClassIntrospection = hClass, Equal, Not Equal) == [Error: Type mismatch: wanted Object, got Class Instead] Casting of classes to objects as in the declaration, Dim hObject As Object = MMain would retain the useful behavior of resulting in introspection objects: hObject Is ClassIntrospection == True I think this reformulation of the model would avoid the apparent ambiguity and the exceptional status of classes as objects while aiding consistency and maintaining introspection features. What do you think? Do you see any inconsistencies or pitfalls within it? As there is no true function datatype at the moment, there is no true generic solution. (Internally, the function datatype exists, but all non-official things do no exist. By the way I told you nothing). Told me about what? I don't know what you're talking about! ;-) When I need doing these sorts of things, I'm only using dynamic object. And if I have a static class, I transform it into a auto-instanciable dynamic class (like Forms objects, for example). If a class is auto-instanciable, using the class name as an object automatically transforms the gb.Class expression into a reference to the auto-created internal singleton object. So you exactly have the syntax you need. Interesting... I'll play with auto-instantiable classes to grasp its practical benefits. And when I will succeed in implementing a clean global syntax, you will just have to transform your auto-creatable class back to a static class. It sounds like good news! Thanks you for your attention. Keep up the good work! Happy Hacking! -- ,= ,-_-. =. Bruno Félix Rezende Ribeiro (oitofelix) [0x28D618AF] ((_/)o o(\_)) There is no system but GNU; `-'(. .)`-' GNU Linux-Libre is one of its official kernels; \_/ All software must be free as in freedom; signature.asc Description: PGP signature
Re: [Gambas-user] Interpreter's treatment of classes
Em Sat, 12 Apr 2014 23:52:48 +0200 Benoît Minisini gam...@users.sourceforge.net escreveu: I said rubbish, as it already works like that. If you use a gb.Class with something that requests an object, the it is automatically converted to the Class object *except if* the class is auto-creatable. In that case it is converted to the automatic hidden singleton instance. You just gave me the last missing piece of the puzzle! Thank you so much! For a given class named 'CLASS' the expression 'CLASS Is Class' evaluates to 'True' not because 'CLASS' is an instance of the class 'Class', but because in a object context 'CLASS' gets cast to its introspection object which in its turn is an instance of the class 'Class'. It's so obvious and clear now! The interpreter's behavior is perfectly consistent and unambiguous with respect to this matter. I feel I owe you and the operator 'Is' an apology, as I've suggested the interpreter's behavior was somewhat inconsistent. Sorry. In the end it's very good that this has happened. Now this subject is solved once and for all, and available in the mailing list for posterity. That said, I still would love to have a pure class type. It'd be like 'Class' or 'Object' but it wouldn't cast classes from 'gb.Class' to 'gb.Object'. That way we could store classes inside variables, make them accessible under properties and pass them as arguments to methods. Something like: Dim hPureClass As PureClass = MMain TypeOf(MMain) == gb.Class If(hPureClass = Identity(MMain), Equal, Not Equal) == Equal Public Sub Identity(hPureClass As PureClass) TypeOf(hPureClass) == gb.Class Return hPureClass End As far as I can see, it would not disrupt any existing code and would add a feature to the language that allows some things that are not strictly possible now, for example the implementation of callback functions by anonymous references to static or dynamic classes. However, if you happen to think that although being backward compatible this change would be too big or not worthy, it'd be sufficient, although not optimal (or so convenient as it could be), to circumvent the current limitations by being able to (un)cast an introspection 'Class' object to the class it describes, perhaps by a method or property thereof, intended for immediate use (a little bit like virtual classes). So it'd look like: Dim hClass As Class = MMain TypeOf(hClass) == gb.Object TypeOf(hClass.Class) == gb.Class If(hClass.Class = MMain, Equal, Not Equal) == Equal I don't know if it's possible at all given the current implementation of the interpreter. In the case it happens to be possible and relatively easy to implement, it'd solve the biggest drawback presented in this correspondence. Thank you for your attention and interest. Happy Hacking! -- ,= ,-_-. =. Bruno Félix Rezende Ribeiro (oitofelix) [0x28D618AF] ((_/)o o(\_)) There is no system but GNU; `-'(. .)`-' GNU Linux-Libre is one of its official kernels; \_/ All software must be free as in freedom; signature.asc Description: PGP signature -- Put Bad Developers to Shame Dominate Development with Jenkins Continuous Integration Continuously Automate Build, Test Deployment Start a new project now. Try Jenkins in the cloud. http://p.sf.net/sfu/13600_Cloudbees___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] Interpreter's treatment of classes
Em Fri, 11 Apr 2014 16:00:23 +0300 Jussi Lahtinen jussi.lahti...@gmail.com escreveu: However, it doesn't behave as an usual instance of the class 'Class'. For instance, it is impossible to access the public methods and properties defined within the class 'Class' using some expression like 'CLASS-CLASS.SYMBOL' where the meta-syntactic variable 'SYMBOL' is a public symbol of the class 'Class'. Therefore, the assertion that CLASS-CLASS evaluates to some object which is an instance of the class 'Class' is somewhat meaningless underneath the usual concept of class/instance of object oriented programming. If I have understood correctly you are referring to MMain which is module, not normal class. And in modules everything is static automatically. I think you mean they aren't dynamic classes. Modules are static classes by definition, aren't they? Anyway, the reasoning until the paragraph you quoted above is independent of that attribute of classes; I mean, regardless of 'CLASS-CLASS' being static or dynamic every expression described until that paragraph works the same way. In the text I wrote, the differences between dynamic and static classes only show up in the process of obtaining a proper object of the class 'Class' which describes the given class 'CLASS-CLASS', what is perfectly possible for dynamic classes, but I fail to see how to accomplish the same with static classes without the knowledge of its name at compilation time. I will look more closely later. Please do. Thank you. -- ,= ,-_-. =. Bruno Félix Rezende Ribeiro (oitofelix) [0x28D618AF] ((_/)o o(\_)) There is no system but GNU; `-'(. .)`-' GNU Linux-Libre is one of its official kernels; \_/ All software must be free as in freedom; signature.asc Description: PGP signature -- Put Bad Developers to Shame Dominate Development with Jenkins Continuous Integration Continuously Automate Build, Test Deployment Start a new project now. Try Jenkins in the cloud. http://p.sf.net/sfu/13600_Cloudbees___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
Re: [Gambas-user] Interpreter's treatment of classes
which are more object-like. However, making them first-class citizens is a first step towards reflection[1], don't you think? Is Gambas in any way a reflexive language? Do you suggest a fourth way of implementing the callback function? Is there a standard or ad-hoc way I'm missing? There is the way I described above, there is the Eval() function which _may_ suffice for your needs and there is another possibility: define your interfaces. The idea you described above was my first implementation. Thinking better now, it's actually a good method. The flaw I saw within it is not a real concern; it was just a (perhaps silly) matter of style. Indeed the 'Eval' function will be of opportune use when I start to think about functions only known at runtime. Define my own interfaces? Hummm... let me see... If your Plot object has a plottee (how I call the object providing plot data), require that the plottee exhibits a specific interface which the interpreter can check. It works like this: 1) Create a non-creatable Plottee.class and define a method to access points for the plot from it. This is the base class for all things that can deliver plot data. 2) In your Plotter.class, request a Plottee object as an argument to get your points. Consequently, your user has to define their own Plottee-like class to interface with your Plotter logic, by inheriting the Plottee.class. The interpreter will check if they inherits correctly (which includes overriding methods and properties with the correct signature). Attached is a project that shows this. If you, e.g., declare _next() in EvalPlottee as returning an Integer or anything not PointF, the interpreter will raise a runtime error. That's a good idea! My current implementation does kind of that, I mean, it defines a Plottee class, which the Plotter class uses for retrieving the points. However I was struggling with how to make the Plottee class instantiate objects which could use arbitrary functions. So I've resorted to implement it in an obscure way referencing objects and methods by its name and checking its signatures. As you have shown it turns out to not be necessary at all. Notwithstanding, it was very useful to learn about the guts of class treatment; the issue which originated this correspondence. :-) There is only a down side of this interface method: every new function needs a entire new class to implement it. Furthermore it's only useful for functions known at compilation time. There may also be some things you didn't know yet. Feel free to ask. Thanks, I took note of that. I won't be shy. :-) This may not be best way. Actually, I find it myself way too Java-like but I'm hungry and this mail stands between me and dinner. You should also consider the event-based approach outlined above which is more like how things are done in Gambas. Yeah, perhaps the initial event-driven interface is actually the best one. Thank you so much for the enlightening response and source code examples. Happy Hacking! [1] https://en.wikipedia.org/wiki/Reflection_%28computer_programming%29 -- ,= ,-_-. =. Bruno Félix Rezende Ribeiro (oitofelix) [0x28D618AF] ((_/)o o(\_)) There is no system but GNU; `-'(. .)`-' GNU Linux-Libre is one of its official kernels; \_/ All software must be free as in freedom; signature.asc Description: PGP signature -- Put Bad Developers to Shame Dominate Development with Jenkins Continuous Integration Continuously Automate Build, Test Deployment Start a new project now. Try Jenkins in the cloud. http://p.sf.net/sfu/13600_Cloudbees___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user
[Gambas-user] Interpreter's treatment of classes
of the function's domain, the event would be raised, so the parent would have to be observing the 'Plot' object to intercept the raised event and then do the calculation. The problem is that by design the event handlers don't return values to the offending object, so the event handler at hand would have to make sure of returning it in some other pre-established manner, like storing the computed point in 'Last.Y', and there would be no check from the interpreter about the implementation following the function's signature and returning a 'Float' value, for example. So, I decided instead to store the object and method's name that implements the mathematical function into the Plot object, so it could call it for the computation of points and invariably receive a return value. But for that to work correctly I needed to check the function's signature. That's why I ultimately came to the issues presented above. One initial hope I had was that 'Function' were a native type of Gambas, as suggested by the expression evaluation 'TypeOf(FUNCTION) == gb.Function', where FUNCTION is the meta-syntactic variable for a function symbol in the current scope. Unfortunately, that turned out to not be true. Is there any reason to not make functions first-class citizens? That would solve my entire problem from the root, albeit the considerations given above are somewhat unrelated and should be considered anyway. Do you suggest a fourth way of implementing the callback function? Is there a standard or ad-hoc way I'm missing? Thank you in advance. -- ,= ,-_-. =. Bruno Félix Rezende Ribeiro (oitofelix) [0x28D618AF] ((_/)o o(\_)) There is no system but GNU; `-'(. .)`-' GNU Linux-Libre is one of its official kernels; \_/ All software must be free as in freedom; signature.asc Description: PGP signature -- Put Bad Developers to Shame Dominate Development with Jenkins Continuous Integration Continuously Automate Build, Test Deployment Start a new project now. Try Jenkins in the cloud. http://p.sf.net/sfu/13600_Cloudbees___ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user