PDA

View Full Version : Polymorphism



Feroc1ty
11-30-2009, 09:58 PM
Does scar have any form of polymorphism because I would find it useful for a function I'm making.

morttt
11-30-2009, 11:21 PM
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.

Brain
11-30-2009, 11:26 PM
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. :spongebob: but funny

FEAR
11-30-2009, 11:43 PM
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.

They have different genotypes so it may affect their phenotype If the different genotype is Dominant :p

Bobarkinator
12-01-2009, 12:27 AM
Feroc1ty, no I don't believe so.

r4it
12-01-2009, 02:12 AM
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

Feroc1ty
12-01-2009, 10:00 PM
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);

Awkwardsaw
12-01-2009, 10:01 PM
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.

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 :p

so you can have as many params as you wish :) you just need to keep track of it all :(

noidea
12-01-2009, 10:33 PM
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

senrath
12-01-2009, 11:24 PM
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.

Awkwardsaw
12-01-2009, 11:49 PM
Nope, sorry. SCAR cannot handle overloading methods.

unless you just make them all into a single array. ;)

Feroc1ty
12-02-2009, 12:03 AM
sigh woulda been too perfect to have that available, shoulda known that by now, anything you want you probly wont get

Awkwardsaw
12-02-2009, 12:04 AM
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?

Blumblebee
12-02-2009, 12:05 AM
well, what exactly do you want?

I'm thinking maybe polymorphism in SCAR?

Awkwardsaw
12-02-2009, 12:06 AM
I'm thinking maybe polymorphism in SCAR?

... what do you want in the function?

Feroc1ty
12-02-2009, 12:09 AM
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.

Awkwardsaw
12-02-2009, 01:14 AM
although this may be useless, and a little confusing/ messy, but this is a little example.

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

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?

Feroc1ty
12-02-2009, 01:42 AM
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.

Awkwardsaw
12-02-2009, 01:43 AM
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

Bobarkinator
12-02-2009, 03:59 AM
although this may be useless, and a little confusing/ messy, but this is a little example.

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

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.

Boreas
12-02-2009, 04:26 AM
'A_string_with_parameters_separated_by_underscores _would_have_the_same_problem', so FunctionBlah and FunctionBlahEx ftw imo

Dan Cardin
12-02-2009, 11:51 AM
one could use a set to make AwkwardSaw's thing look prettier, if that helped anything.

weequ
12-02-2009, 10:29 PM
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...)

ape
12-02-2009, 10:51 PM
You cannot. This is a feature in object oriented programming languages such as java or c++.