Results 1 to 24 of 24

Thread: Polymorphism

  1. #1
    Join Date
    Feb 2008
    Posts
    517
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default Polymorphism

    Does scar have any form of polymorphism because I would find it useful for a function I'm making.

  2. #2
    Join Date
    Nov 2009
    Posts
    27
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    All Scars have the same phenotypes, so i don't think Scars are polymorphic.

    But of course Scars don't belong to a panmictic population anyway, so the whole question of polymorphism is irrelevant. They do, however, occupy the same habitat at the same time, so i can see where the idea came from.

  3. #3
    Join Date
    Dec 2007
    Location
    Williston, ND
    Posts
    3,106
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by morttt View Post
    All Scars have the same phenotypes, so i don't think Scars are polymorphic.

    But of course Scars don't belong to a panmictic population anyway, so the whole question of polymorphism is irrelevant. They do, however, occupy the same habitat at the same time, so i can see where the idea came from.
    lol? I don't think he is talking about biology. but funny
    Proud owner of "Efferator" my totally boted main account!
    "You see, sometimes, science is not a guess" -Xiaobing Zhou (my past physics professor, with heavy Chinese accent)

  4. #4
    Join Date
    Jan 2008
    Location
    Houston, Texas, USA
    Posts
    770
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by morttt View Post
    All Scars have the same phenotypes, so i don't think Scars are polymorphic.

    But of course Scars don't belong to a panmictic population anyway, so the whole question of polymorphism is irrelevant. They do, however, occupy the same habitat at the same time, so i can see where the idea came from.
    [Offtopic]They have different genotypes so it may affect their phenotype If the different genotype is Dominant [/Offtopic]

  5. #5
    Join Date
    Jan 2007
    Location
    Kansas
    Posts
    3,760
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    Feroc1ty, no I don't believe so.


  6. #6
    Join Date
    Nov 2009
    Posts
    14
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    In computer science, polymorphism is a programming language feature that allows values of different data types to be handled using a uniform interface. The concept of parametric polymorphism applies to both data types and functions. A function that can evaluate to or be applied to values of different types is known as a polymorphic function. A data type that can appear to be of a generalized type (e.g., a list with elements of arbitrary type) is designated polymorphic data type like the generalized type from which such specializations are made.
    pl0x

  7. #7
    Join Date
    Feb 2008
    Posts
    517
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Well, is there any way I can make a function or a procedure take extra optional parameters?

    Ex:

    Procedure(opt1,opt2);

    Procedure(opt1,opt2,opt3);

  8. #8
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    wait, from just guessing at what that quote means, a polymorphanism is a function that returns multiple value types, like string, integer, boolean ect?

    also, just make the params an array.

    SCAR Code:
    function dothis(arr: TVariantArray):variant;
    var i : integer;
    begin
      for i := 0 to 3 do
         writeln(arr[i]);
    end;

    ect. ect. of course, you can make this do what ever you want, with any type you want

    so you can have as many params as you wish you just need to keep track of it all
    Last edited by Awkwardsaw; 12-01-2009 at 10:06 PM.
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  9. #9
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    Or changing the type?
    In java:

    byte i = 3;
    System.out.println((int)i);// <-- Changes the byte to an int type

    I think you can do it with chars (actually 100% possitive) just havent tested.
    You would do that in SCAR by

    writeln(Integer(i)); I think :S
    Quote Originally Posted by irc
    [00:55:29] < Guest3097> I lol at how BenLand100 has become noidea
    [01:07:40] <@BenLand100> i'm not noidea i'm
    [01:07:44] -!- BenLand100 is now known as BenLand42-
    [01:07:46] <@BenLand42-> shit
    [01:07:49] -!- BenLand42- is now known as BenLand420
    [01:07:50] <@BenLand420> YEA

  10. #10
    Join Date
    Oct 2006
    Location
    ithurtsithurtsithurtsithurts
    Posts
    2,930
    Mentioned
    7 Post(s)
    Quoted
    135 Post(s)

    Default

    Quote Originally Posted by Feroc1ty View Post
    Well, is there any way I can make a function or a procedure take extra optional parameters?

    Ex:

    Procedure(opt1,opt2);

    Procedure(opt1,opt2,opt3);
    Nope, sorry. SCAR cannot handle overloading methods.

  11. #11
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    Quote Originally Posted by senrath View Post
    Nope, sorry. SCAR cannot handle overloading methods.
    unless you just make them all into a single array.
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  12. #12
    Join Date
    Feb 2008
    Posts
    517
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    sigh woulda been too perfect to have that available, shoulda known that by now, anything you want you probly wont get

  13. #13
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    Quote Originally Posted by Feroc1ty View Post
    sigh woulda been too perfect to have that available, shoulda known that by now, anything you want you probly wont get
    well, what exactly do you want?
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  14. #14
    Join Date
    Feb 2007
    Location
    Alberta,Canada
    Posts
    2,358
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Awkwardsaw View Post
    well, what exactly do you want?
    I'm thinking maybe polymorphism in SCAR?

  15. #15
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    Quote Originally Posted by Blumblebee View Post
    I'm thinking maybe polymorphism in SCAR?
    ... what do you want in the function?
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  16. #16
    Join Date
    Feb 2008
    Posts
    517
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    I want the function to be able to take 2 or 3 parameters, so whenever someone uses the include they wouldn't have to memorize 2 different functions, and simply add in an extra parameter if need be.

  17. #17
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    although this may be useless, and a little confusing/ messy, but this is a little example.

    SCAR Code:
    program New;
    {.Include SRL/SRL.scar}

    function isbool(v : variant):boolean;
    begin
      try
        if v or (not v) then
          result := true;
      except
      end;
    end;

    function mouseuptext(Arr : TVariantarray): boolean;
    begin
      mmouse(arr[0], arr[1], arr[2], arr[3]);
      if high(arr) >= 5 then
        if arr[5] <> null then
        begin
          result := isuptext(arr[5]);
          if not result then exit;
        end;
      result := true;
      if (high(arr) < 4) then exit;
        if not isbool(arr[4]) then
          exit;
        mouse(arr[0], arr[1], arr[2], arr[3], arr[4]);
    end;

    begin        //[x, y, rx, ry, left(opt), uptext(opt)]
      mousespeed := 15;
      mouseuptext([306, 280, 0, 0]);
    end.

    if you test it out, and mess with it a little bit, this will either move the mouse, move the mouse, and check the uptext, both and click the mouse, or just click the mouse depending on what parameters you set up.

    where
    SCAR Code:
    mouseuptext([306, 280, 0, 0, true, 'wat']);

    you NEED the first 4 parameters, if you do not want to click, then make "true" to 0, or ''. if you dont want to check an uptext, then simply dont set that parameter. if you just want to move the mouse, just fill in the first 4 parameters

    am i helping/ making sence?
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  18. #18
    Join Date
    Feb 2008
    Posts
    517
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    no point in trying to add confusing crap to bypass the issue, was simply seeing if i could make it simpler but ill just make 2 functions instead of having 1.

  19. #19
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    Quote Originally Posted by Feroc1ty View Post
    no point in trying to add confusing crap to bypass the issue, was simply seeing if i could make it simpler but ill just make 2 functions instead of having 1.
    i know

    just being different, and it may help you out if you do it correctly
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  20. #20
    Join Date
    Jan 2007
    Location
    Kansas
    Posts
    3,760
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by Awkwardsaw View Post
    although this may be useless, and a little confusing/ messy, but this is a little example.

    SCAR Code:
    program New;
    {.Include SRL/SRL.scar}

    function isbool(v : variant):boolean;
    begin
      try
        if v or (not v) then
          result := true;
      except
      end;
    end;

    function mouseuptext(Arr : TVariantarray): boolean;
    begin
      mmouse(arr[0], arr[1], arr[2], arr[3]);
      if high(arr) >= 5 then
        if arr[5] <> null then
        begin
          result := isuptext(arr[5]);
          if not result then exit;
        end;
      result := true;
      if (high(arr) < 4) then exit;
        if not isbool(arr[4]) then
          exit;
        mouse(arr[0], arr[1], arr[2], arr[3], arr[4]);
    end;

    begin        //[x, y, rx, ry, left(opt), uptext(opt)]
      mousespeed := 15;
      mouseuptext([306, 280, 0, 0]);
    end.

    if you test it out, and mess with it a little bit, this will either move the mouse, move the mouse, and check the uptext, both and click the mouse, or just click the mouse depending on what parameters you set up.

    where
    SCAR Code:
    mouseuptext([306, 280, 0, 0, true, 'wat']);

    you NEED the first 4 parameters, if you do not want to click, then make "true" to 0, or ''. if you dont want to check an uptext, then simply dont set that parameter. if you just want to move the mouse, just fill in the first 4 parameters

    am i helping/ making sence?
    Then you don't get code hints which makes it even harder.


  21. #21
    Join Date
    Sep 2006
    Posts
    5,219
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    'A_string_with_parameters_separated_by_underscores _would_have_the_same_problem', so FunctionBlah and FunctionBlahEx ftw imo

  22. #22
    Join Date
    Apr 2007
    Posts
    3,152
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    one could use a set to make AwkwardSaw's thing look prettier, if that helped anything.
    SCAR Tutorials: The Form Tutorial | Types, Arrays, and Classes
    Programming Projects: NotePad | Tetris | Chess


  23. #23
    Join Date
    Nov 2006
    Posts
    2,369
    Mentioned
    4 Post(s)
    Quoted
    78 Post(s)

    Default

    Actually im not sure what is this all about but this could help: http://www.villavu.com/forum/showthread.php?t=43158 (most likely a whole different thing...)

  24. #24
    Join Date
    Apr 2008
    Posts
    89
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    You cannot. This is a feature in object oriented programming languages such as java or c++.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •