Questions tagged [sigils]

Symbols attached to variable names, showing datatype or scope.

A sigil is a symbol attached to a variable name, showing the variable's datatype or scope.

For instance in Perl, $ is the sigil denoting scalar type of the variable $foo, while @ is the sigil denoting the array type of @foo.

For more information and a list of other languages featuring sigils, see the Wikipedia article on sigils.

30 questions
55
votes
5 answers

What is the difference between `$this`, `@that`, and `%those` in Perl?

What is the difference between $this, @that, and %those in Perl?
Mare
  • 567
  • 4
  • 3
16
votes
2 answers

Significance of an ampersand in VB6 function name?

I just got a bunch of legacy VB6 (!) code dumped on me and I keep seeing functions declared with an ampersand at the end of the name, for example, Private Declare Function ShellExecute& . . .. I've been unable to find an answer to the significance…
Ickster
  • 2,167
  • 4
  • 22
  • 43
15
votes
2 answers

What's the benefit of assigning non-scalars to scalars?

I sometimes see code that (to me) uses the wrong sigil in front of the variable my $arr = [1, 2, 3, 4, 5]; # an array my $lst = (1, 2, 3, 4, 5); # a list my $hash = {a => '1', b => '2'}; # a hash my $func = -> $foo { say $foo }; # a…
Electric Coffee
  • 11,733
  • 9
  • 70
  • 131
13
votes
2 answers

When does it make sense to use a sigil-less variable in Raku?

Raku sigils denote the nature of the underlying variable (e.g., $scalar, @positional, %associative, &code). It's possible to declare a variable as sigil-less with a backslash (e.g., \some-variable) and then later refer to it without a sigil (i.e.,…
user2145475
  • 657
  • 3
  • 11
13
votes
4 answers

Can PHP be used without the dollar sign $ symbol for variables?

Is it possible to name variables in a Java-like manner in PHP, such as by removing the need for a $ sign each time? If so, how can I enable the setting which does this?
Ali
  • 261,656
  • 265
  • 575
  • 769
12
votes
9 answers

Why do you need $ when accessing array and hash elements in Perl?

Since arrays and hashes can only contain scalars in Perl, why do you have to use the $ to tell the interpreter that the value is a scalar when accessing array or hash elements? In other words, assuming you have an array @myarray and a hash %myhash,…
Lorin Hochstein
  • 57,372
  • 31
  • 105
  • 141
8
votes
1 answer

perl6: do I need the @-sigil for userdefined variables?

Is there something I can't do without the '@'-sigil when working with user-defined variables? #!perl6 use v6; my $list = ; my @list = ; $list.list.perl.say; @list.perl.say;…
sid_com
  • 24,137
  • 26
  • 96
  • 187
7
votes
1 answer

What is @$ in perl?

I came across this, expecting it to be a typo for $@: use strict; use warnings; eval { my $error = Not::Here->new(); }; warn @$; And to my surprise it outputs this: Can't locate object method "new" via package "Not::Here" (perhaps you forgot…
bolav
  • 6,938
  • 2
  • 18
  • 42
4
votes
1 answer

perl 6 variable same name different sigils inconsistent behavior

There seems to be some inconsistent behavior when variables of the same letter-name but different sigils are used: > my $a="foo"; foo > my @a=1,2 [1 2] > say $a foo # this is what I have expected > my $b = 1,2,3 (1 2 3) > my @b = (0,…
lisprogtor
  • 5,677
  • 11
  • 17
3
votes
2 answers

Dealing with WCF in iPhone/iPad project

I'm trying to make my Monotouch app work with WCF service. Everything works fine but every now and then (10 - 30 service calls), app crashes with SIGIL. Debugger says just that. It happens on random places. Another employee works on iPhone app which…
Mr Q
  • 127
  • 8
3
votes
1 answer

What does this mean "jQuery(function ($) {})"?

What does the below line mean? It passes function($) as a parameter into jQuery? jQuery(function ($) { // ... });
Axar
  • 521
  • 1
  • 3
  • 11
2
votes
1 answer

what's meaning of `~w(username full_name password)a`?

In hexpm project, The line cast(%User{}, params, ~w(username full_name password)a). I know it may be equal to [:username, :full_name,:password], but why? What's the meaning of ~w and a? def build(params, confirmed? \\ not…
Chen Yu
  • 3,955
  • 1
  • 24
  • 51
2
votes
5 answers

How do languages whose variables don't have sigils deal with dynamic dispatch/invocation?

Dynamic languages allow dispatching with and invoking on values from variables whose values are only known at run-time. Contrasting examples in Perl: class…
daxim
  • 39,270
  • 4
  • 65
  • 132
2
votes
1 answer

String substitution in ruby depends on variable's first character

After I thought the variable scope would be the reason I got the hint, that substitution depends on if the first character of a variable is a letter/underscore or not. But I don't understand the intention. Let's take this example: $var1 =…
user3622011
1
vote
4 answers

What scope does an "at" sigil (@) give within Ruby functions?

It's been a while since I last did Ruby programming -- looking at somebody else's code, I see the @ sigil in a function (not a method -- external to any class definition), which I understood to be scoped to instance members. Is the module the…
cdleary
  • 69,512
  • 53
  • 163
  • 191
1
2