Re: [Gambas-user] More on overriding native classes

2012-07-08 Thread Fabien Bodard
2012/7/4 Benoît Minisini gam...@users.sourceforge.net

 Le 04/07/2012 07:55, Fabien Bodard a écrit :
  why if the class have the same name of an existing one you not just
 ignore
  the 'inherit' keyword, Benoit ?
 

 Because the compiler does not know that a class with the same name
 already exists at compile time.


ok


 --
 Benoît Minisini




 --
 Live Security Virtual Conference
 Exclusive live event will cover all the ways today's security and
 threat landscape has changed and how IT managers can respond. Discussions
 will include endpoint security, mobile security and the latest in malware
 threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
 ___
 Gambas-user mailing list
 Gambas-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/gambas-user




-- 
Fabien Bodard
--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] More on overriding native classes

2012-07-04 Thread Benoît Minisini
Le 04/07/2012 07:55, Fabien Bodard a écrit :
 why if the class have the same name of an existing one you not just ignore
 the 'inherit' keyword, Benoit ?


Because the compiler does not know that a class with the same name 
already exists at compile time.

-- 
Benoît Minisini



--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] More on overriding native classes

2012-07-03 Thread Benoît Minisini
Le 25/06/2012 10:33, Bruce a écrit :
 OK, but not the answer I was hoping for.

 Presumably Application is needed early on in the piece.  What I'm
 trying to work out is, if I override Application then which order does

  gb.Application._Init()
 ^
 |
  gb.qt4.Application._Init()
 ^
 |
  (my) Application.Init()

 get executed.

gb.Application._Init() first, then gb.qt4.Application._Init, then yours.

_Init is run when the class is loaded, so the order of execution follows 
the order of inheritance or overriding.

Regards,

-- 
Benoît Minisini



--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] More on overriding native classes

2012-06-25 Thread Bruce
On Mon, 2012-06-25 at 00:47 +0200, Benoît Minisini wrote:
 Le 25/06/2012 00:41, Bruce a écrit :
 
  If you export a class with a name that already exists, it automatically
  implies inheritance with overriding.
 
  So you have a multiple inheritance error by using the Inherits keyword.
 
 
  Wow! That simple.
  Now I can do all those nefarious things I've always wanted :-)
 
  Oh, but wait, one question.
 
  Class initialisation must occur in some specific order (like
  constructors and inherited classes), what is it and is there any way to
  control it? e.g. by the order of the components and libraries in
  the .startup file?
 
  Bruce
 
 
 The only rule if that a class is initialized the first time it is needed.
 
OK, but not the answer I was hoping for.

Presumably Application is needed early on in the piece.  What I'm
trying to work out is, if I override Application then which order does 

gb.Application._Init()
   ^
   |
gb.qt4.Application._Init()
   ^
   |
(my) Application.Init()

get executed.

Why? Because my override is dependent on some of the gb.Application
statics. Therefore I need it to execute after the
gb.Application._Init, so that I can access these static properties
without having to implement a late static StartMeUp method in my
project's Main method to set the static Properties I want.

What's even worse is that what I really,really want is
my.Application._Init to be executed after some gb.db.***._Init()'s  have
occurred.  But I think that is not possible.

If you could just clarify the execution order of the inheritance chain
_Init()'s I might find a way around the (nefarious) things I'm trying to
do?

Bruce






--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] More on overriding native classes

2012-06-24 Thread Benoît Minisini
Le 18/06/2012 15:29, Bruce a écrit :
 On Mon, 2012-06-18 at 22:39 +0930, Bruce wrote:

 Try this:
 Create a new command line project in the IDE.
 Add a new class Application with the following contents

  ' Gambas class file

  Create Static
  Inherits Application
  Export

  Static Public Hello As String = Hello from South Australia

 Save and reload the project.
 In MMain.Main type the following:

  ?appl[Enter].he

 ( see screenshot appended)
 Now that, to me, looks like we have successfully overridden the
 Application class, but look what happens when you run it.


 Let me rephrase that (sometimes the keyboard is quicker than the mind.)

 Try this:
 Create a new command line project in the IDE.
 Add a new class Application with the following contents

 ' Gambas class file

 Create Static
 Inherits Application

 Static Public Hello As String = Hello from South Australia

 Save and reload the project.
 In MMain.Main type the following:

 ?appl[Enter].he

 ( see new! screenshot appended)
 Now that, to me, looks like we have successfully overridden the
 Application class, but look what happens when you run it.


 What you should see is a very correct error message saying that Hello
 is an unknown method in Application.  That is because it hasn't been exported.
 But when I go back and export the class, then I get the Multiple Inheritance 
 error.

 B


If you export a class with a name that already exists, it automatically 
implies inheritance with overriding.

So you have a multiple inheritance error by using the Inherits keyword.

-- 
Benoît Minisini



--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] More on overriding native classes

2012-06-24 Thread Bruce
On Sun, 2012-06-24 at 22:52 +0200, Benoît Minisini wrote:
 Le 18/06/2012 15:29, Bruce a écrit :
  On Mon, 2012-06-18 at 22:39 +0930, Bruce wrote:
 
  Try this:
  Create a new command line project in the IDE.
  Add a new class Application with the following contents
 
   ' Gambas class file
 
   Create Static
   Inherits Application
   Export
 
   Static Public Hello As String = Hello from South Australia
 
  Save and reload the project.
  In MMain.Main type the following:
 
   ?appl[Enter].he
 
  ( see screenshot appended)
  Now that, to me, looks like we have successfully overridden the
  Application class, but look what happens when you run it.
 
 
  Let me rephrase that (sometimes the keyboard is quicker than the mind.)
 
  Try this:
  Create a new command line project in the IDE.
  Add a new class Application with the following contents
 
  ' Gambas class file
 
  Create Static
  Inherits Application
 
  Static Public Hello As String = Hello from South Australia
 
  Save and reload the project.
  In MMain.Main type the following:
 
  ?appl[Enter].he
 
  ( see new! screenshot appended)
  Now that, to me, looks like we have successfully overridden the
  Application class, but look what happens when you run it.
 
 
  What you should see is a very correct error message saying that Hello
  is an unknown method in Application.  That is because it hasn't been 
  exported.
  But when I go back and export the class, then I get the Multiple 
  Inheritance error.
 
  B
 
 
 If you export a class with a name that already exists, it automatically 
 implies inheritance with overriding.
 
 So you have a multiple inheritance error by using the Inherits keyword.
 

Wow! That simple.  
Now I can do all those nefarious things I've always wanted :-)

Oh, but wait, one question.

Class initialisation must occur in some specific order (like
constructors and inherited classes), what is it and is there any way to
control it? e.g. by the order of the components and libraries in
the .startup file?

Bruce


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] More on overriding native classes

2012-06-24 Thread Benoît Minisini
Le 25/06/2012 00:41, Bruce a écrit :

 If you export a class with a name that already exists, it automatically
 implies inheritance with overriding.

 So you have a multiple inheritance error by using the Inherits keyword.


 Wow! That simple.
 Now I can do all those nefarious things I've always wanted :-)

 Oh, but wait, one question.

 Class initialisation must occur in some specific order (like
 constructors and inherited classes), what is it and is there any way to
 control it? e.g. by the order of the components and libraries in
 the .startup file?

 Bruce


The only rule if that a class is initialized the first time it is needed.

-- 
Benoît Minisini



--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


[Gambas-user] More on overriding native classes

2012-06-18 Thread Bruce
The previous topic has reminded me of something.

Contrary to what is said or implied in section 3.2 of the Object Model
help topic, it is not possible to override several if not many native
classes.

Two particular instances leap to mind, Application and Error.

Try this:
Create a new command line project in the IDE.
Add a new class Application with the following contents

' Gambas class file

Create Static
Inherits Application
Export

Static Public Hello As String = Hello from South Australia

Save and reload the project.
In MMain.Main type the following:

?appl[Enter].he

( see screenshot appended)
Now that, to me, looks like we have successfully overridden the
Application class, but look what happens when you run it.

Similar things happen with Error and Class. Probably more.

To keep this one short, why would I want to override Application?
So I can get at more of what is in the .project file, sort of more
introspection than is currently there.

Any thoughts or comments?  (This is a discussion post, not a bug. That
is unless I've got it totally worng agian. Which given my recent strike
rate could be a possibility.)

Bruce
attachment: shot3.png--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] More on overriding native classes

2012-06-18 Thread Bruce
On Mon, 2012-06-18 at 22:39 +0930, Bruce wrote:

 Try this:
 Create a new command line project in the IDE.
 Add a new class Application with the following contents
 
 ' Gambas class file
 
 Create Static
 Inherits Application
 Export
 
 Static Public Hello As String = Hello from South Australia
 
 Save and reload the project.
 In MMain.Main type the following:
 
 ?appl[Enter].he
 
 ( see screenshot appended)
 Now that, to me, looks like we have successfully overridden the
 Application class, but look what happens when you run it.
 

Let me rephrase that (sometimes the keyboard is quicker than the mind.)

Try this:
Create a new command line project in the IDE.
Add a new class Application with the following contents

   ' Gambas class file
   
   Create Static
   Inherits Application
   
   Static Public Hello As String = Hello from South Australia

Save and reload the project.
In MMain.Main type the following:

   ?appl[Enter].he

( see new! screenshot appended)
Now that, to me, looks like we have successfully overridden the
Application class, but look what happens when you run it.


What you should see is a very correct error message saying that Hello
is an unknown method in Application.  That is because it hasn't been exported.
But when I go back and export the class, then I get the Multiple Inheritance 
error.

B


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user