Hi James,

Can you be a little more specific in what you are trying to do?

If the procedures are in different scopes they can have the same name.

You can redefine a method in an inherited class (with some limitations)

You can use the same name in many class definitions without restriction if they do not inherit.

The example below uses the proc / method named testing in the above mentioned ways.



Bob
file test.curl ***************************************

{curl 5.0 applet}
{curl-file-attributes character-encoding = "windows-latin-1"}

{import * from testp, location = {url "./load.scurl"}}

{define-proc {testing in:int}:int  || applet scope
   {return in+10}
}

{define-class Parent
 {method public {testing in:int}:int || parent method
   {return in+10}
 }
}

{define-class Child {inherits Parent}
 {method public {testing in:int}:int  || child method
   {return {super.testing in} + 100}  || use parent method
 }
}

{define-class Unrelated
 {method public {testing}:String  || unrelated so no restrictions
   {return "Hi - I am unrelated"}
 }
}

{value
   let a:Parent = {Parent}
   let b:Child = {Child}
   let c:Unrelated = {Unrelated}
{VBox {testing 1}, || applet scope
       {testing {try-me 2}},    || applet scope and package scope
       {a.testing 3},           || parent method
       {b.testing 4},           || child method - that uses parent method
       {c.testing}              || unrelated method
   }
}

file load.scurl **********************************************

{curl 5.0 package}
{curl-file-attributes character-encoding = "windows-latin-1"}
{package testp}

{define-proc {testing in:int}:int  || scoped in package
   {return in+100}
}

{define-proc public {try-me in:int}:int
   {return {testing in}}  || uses package call
}

JamesWang wrote:
Hello
Does Curl support method or procedure override?

I can define two procedures with the same name in Curl.Does it mean Curl
does not support that?

James



----------------------------------------------------------------------------------------------
Confidentiality Notice: The information contained in this e-mail and any accompanying attachment(s) is intended only for the use of the intended recipient and may be confidential and/or privileged of Neusoft Group Ltd., its subsidiaries and/or its affiliates. If any reader of this communication is not the intended recipient, unauthorized use, forwarding, printing, storing, disclosure or copying is strictly prohibited, and may be unlawful. If you have received this communication in error, please immediately notify the sender by return e-mail, and delete the original message and all copies from your system. Thank you. -----------------------------------------------------------------------------------------------




__________ NOD32 1.1797 (20061010) Information __________

This message was checked by NOD32 antivirus system.
http://www.eset.com




Reply via email to