SRL Archive - Classic

Polymorphism


Feroc1ty

2009-11-30 16:58:18

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

morttt

2009-11-30 18:21:01

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

2009-11-30 18:26:49

From: morttt
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

2009-11-30 18:43:53

From: morttt
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 :p [/Offtopic]

Bobarkinator

2009-11-30 19:27:16

Feroc1ty, no I don't believe so.

r4it

2009-11-30 21:12:14


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

2009-12-01 17:00:41

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

2009-12-01 17:01:41

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

2009-12-01 17:33:20

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

2009-12-01 18:24:54

From: Feroc1ty
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

2009-12-01 18:49:48

From: senrath
Nope, sorry. SCAR cannot handle overloading methods.


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

Feroc1ty

2009-12-01 19:03:01

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

Awkwardsaw

2009-12-01 19:04:30

From: Feroc1ty
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

2009-12-01 19:05:32

From: Awkwardsaw
well, what exactly do you want?


I'm thinking maybe polymorphism in SCAR?

Awkwardsaw

2009-12-01 19:06:59

From: Blumblebee
I'm thinking maybe polymorphism in SCAR?


… what do you want in the function?

Feroc1ty

2009-12-01 19:09:11

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

2009-12-01 20:14:55

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

2009-12-01 20:42:09

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

2009-12-01 20:43:53

From: Feroc1ty
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

2009-12-01 22:59:28

From: Awkwardsaw
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

2009-12-01 23:26:30

'A_string_with_parameters_separated_by_underscores_would_have_the_same_problem', so FunctionBlah and FunctionBlahEx ftw imo

Dan Cardin

2009-12-02 06:51:24

one could use a set to make AwkwardSaw's thing look prettier, if that helped anything.

weequ

2009-12-02 17:29:42

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

2009-12-02 17:51:37

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