Questions tagged [signature]

In computer programming, especially object-oriented programming, a method is commonly identified by its unique method signature, which usually includes the method name, and the number, types and order of its parameters. A method signature is the smallest type of a method. The signature tag should not be used to tag questions about digital signatures, email signatures or written signatures.

Method signature

In computer programming, especially object-oriented programming, a method is commonly identified by its unique method signature, which usually includes the method name, and the number, types and order of its parameters. A method signature is the smallest type of a method.

Method overloading

Method signatures can be used by the compiler to distinguish between methods with the same name, but with different parameters. This is called method overloading. The precise characteristics of method overloading depends on the programming language. Overloading should not be used for methods that perform an different operation as that will make the source code hard to read.

Examples

Example of declarations of two overloaded methods with the same name, but with a different method signature:

void drawPoint(int x, int y);
void drawPoint(Point p);

in this case it is likely that drawPoint(x, y) internally converts x and y into a Point instance. This kind of function is therefore called a convenience method.

Disambiguation

For digital signatures such as RSA or DSA signatures please use and/or . Email may contain an email-signature, PDF documents may contain a digitized written signature. These signatures don't have specialized tags, please use more generic tags such as and instead.

2003 questions
8
votes
1 answer

Signatures smartmatching misunderstanding

While reading and trying signature smartmatching I run into something strange. Executing the following smartmaching signature pairs: my @sigs = :($a, $b), :($a, @b), :($a, %b); my @signatures_to_check = :($, $), :($, @), :($, %); my $c = 0; for…
jakar
  • 1,701
  • 5
  • 14
8
votes
1 answer

What's the convention for when you offer an async variant of the same code?

Let foo be sub or method. I have programmed a blocking and an async variant, so looking from the outside the essential difference is in the return value. I first thought of specifying it in the signature, but the dispatcher unfortunately only looks…
daxim
  • 39,270
  • 4
  • 65
  • 132
8
votes
2 answers

Perl6; multi sub

For the following multi sub script: multi sub Screen_get_valid_string($prompt, $accept_empty_string, $max_length = 999) { return "abc" } multi sub Screen_get_valid_string($prompt, $max_length = 999) { return "def" } my $return…
pcarrier
  • 141
  • 2
8
votes
2 answers

Perl6 - What is the $: for in some subroutine Signatures

I came across this error message in another question and I would like to know what is the meaning of the $: part of the signature, please? Cannot resolve caller index(Str: Str, Any); none of these signatures match: (Str:D $: Cool:D $needle,…
librasteve
  • 6,832
  • 8
  • 30
8
votes
2 answers

How can I convert a Str to an Int only when it represents an integer?

In Perl 6 you can specify a type that a type can be coerced to. For example, you need an Int but get something else that can convert to an Int. This is handy when you don't want separate candidates for Int and Str where the string represents an…
brian d foy
  • 129,424
  • 31
  • 207
  • 592
8
votes
2 answers

What are use cases for F# module signature files?

Are F# module signature files mostly useless, unlike OCaml, because F# doesn't have functors? What are use cases for F# module signature files?
nau
  • 1,145
  • 8
  • 20
8
votes
8 answers

How to produce XML signature with no whitespaces and line-breaks in Java?

I work with the brazilian "Nota Fiscal Eletronica" project, in which they define a standart way to sign XML documents. Recently, they started to require that there are absolutely no whitespaces between tags, including signature tags (*). We happen…
Jonathas Carrijo
  • 743
  • 2
  • 7
  • 14
8
votes
3 answers

How do I specify a Perl 6 signature that encompasses everything I accept and excludes everything else?

My assumption in this question is that a signature that I specify completely describes everything that a method will accept. Apparently I'm wrong about that, but I'd like to get that anyway. If I don't specify it in the signature, I don't want other…
brian d foy
  • 129,424
  • 31
  • 207
  • 592
8
votes
2 answers

Haskell Deriving Mechanism for Agda

I am wondering if there is anything in Agda that resembles Haskell's deriving Eq clause ---then I have an associated question below, as well. For example, suppose I have types for a toy-language, data Type : Set where Nat : Type Prp :…
Musa Al-hassy
  • 982
  • 1
  • 7
  • 12
8
votes
1 answer

Two methods with same erasure aren't necessary override-equivalent (or they signatures aren't subsignatures between them)?

Im reading the incredible book “a programmer's guide to java scjp certification” for jdk6 and theres a section about generic overriding. On it is described subsignature and override-equivalent and describes some examples of override-equivalent that…
user1546652
  • 557
  • 1
  • 5
  • 15
8
votes
2 answers

Type signatures that never make sense

Consider (a->a) -> [a] -> Bool Is there any meaningful definition for this signature? That is, a definition that not simply ignores the argument? x -> [a] -> Bool It seems there are many such signatures that can be ruled out immediately.
false
  • 10,264
  • 13
  • 101
  • 209
8
votes
1 answer

What is a parameter signature in PHP?

The PHP official documentation while explaining about extends under classes and objects section, it says: "When overriding methods, the parameter signature should remain the same or PHP will generate an E_STRICT level error. This does not apply to…
Yousuf Memon
  • 4,638
  • 12
  • 41
  • 57
7
votes
2 answers

Define recursive signatures for modules

I know that it is possible to define recursive modules, does anyone know how to define recursive signatures? For instance, I would like to realize: module type AAA = sig module Bbb : BBB type 'a t val f : 'a Bbb.t -> 'a t end module type BBB…
SoftTimur
  • 5,630
  • 38
  • 140
  • 292
7
votes
1 answer

How can I pipe in a string to a Raku program?

foo.raku: #! /usr/bin/env raku use v6.d; sub MAIN (Str $some-text = $*IN.slurp, Bool :$verbose) { say "Your text:" if $verbose; say $some-text; } When I run it ~% echo "Hello World" | ./foo.raku --verbose I get: Your…
Jim Bollinger
  • 1,671
  • 1
  • 13
7
votes
1 answer

How to know file .apk use to the keystore to sign?

I have a keystore and a apk. is there a tool or a method to check file apk, signed from this keystore? I use Eclipse. Someome help me please. Thanks so much
chishi
  • 73
  • 1
  • 4