Questions tagged [anonymous]

DO NOT USE! Please use a more specific tag such as [anonymous-function] or [anonymous-class].

The term anonymous has come to represent different aspects of development with the rise of the functional programming style and the use of anonymous on-demand applications.

In an effort to disambiguate this tag, it has been split into the following subcategories:

Category Description
Anonymous Classes An anonymous class is a local class without a name. An anonymous class is defined and instantiated in a single succinct expression using the new operator.
Anonymous Functions Anonymous functions use a block of code as a value, defining it as an inline function without a name.
Anonymous Methods An anonymous method is a procedure or function that does not have a name associated with it.
Anonymous Types Anonymous types are data types which dynamically add a set of properties into a single object without having to first explicitly define a type
Anonymous Users Anonymous users are individuals or systems that make use of a product or service, without formally registering account details and are instead associated with some token or identifier.

Former Tag Definition

For new questions, see [anonymous-class] and [anonymous-function].

Typically, a programming language construct like a function or class has a name associated with it -- a symbol that can be used to refer to the construct in some context. An anonymous function or class is one that, in contrast to normal practice, has no name. For example, in Java, you can create an anonymous class using a special syntax that defines a class and constructs an instance of it at the same time:

Runnable r = new Runnable() {
    public void run() {
        System.out.println("Running");
    }
};

The variable r holds a reference to an instance of a class which has no name in Java, but which implements the Runnable interface and can be used anywhere a Runnable instance is needed.

702 questions
19
votes
5 answers

Anonymous Namespace Ambiguity

Consider the following snippet: void Foo() // 1 { } namespace { void Foo() // 2 { } } int main() { Foo(); // Ambiguous. ::Foo(); // Calls the Foo in the global namespace (Foo #1). // I'm trying to call the `Foo` that's defined in the…
sharp02
  • 193
  • 1
  • 4
19
votes
5 answers

java thread accessing outer object before it's created

Yes, this is an academic question, I know people will complain that I'm not posting any code but I'm genuinely struck with this question, really don't know where to begin. I would really appreciate an explanation and maybe some code example. If an…
user3363135
  • 370
  • 1
  • 4
  • 12
19
votes
4 answers

C# Conditional Anonymous Object Members in Object initialization

I building the following anonymous object: var obj = new { Country = countryVal, City = cityVal, Keyword = key, Page = page }; I want to include members in object only if its value is present. For example if cityVal is null, I don't…
Tepu
  • 1,602
  • 2
  • 20
  • 28
19
votes
2 answers

TProc to TNotifyEvent

Further to this post whose accepted answer remains very cryptic: @Button1.OnClick := pPointer(Cardinal(pPointer( procedure (sender: tObject) begin ((sender as TButton).Owner as TForm).Caption := 'Freedom to anonymous methods!' end )^ ) + $0C)^; I…
menjaraz
  • 7,551
  • 4
  • 41
  • 81
19
votes
5 answers

Anonymous Namespace Class Definition

I was looking over some (C++) code and found something like this: //Foo.cpp namespace { void SomeHelperFunctionA() {} void SomeHelperFunctionB() {} void SomeHelperFunctionC() {} //etc... class SomeClass //<--- { …
CIU5_8
18
votes
2 answers

S3 - Anonymous Upload - Key prefix

I am trying to understand exactly how to setup a bucket that is generally private but allows anonymous uploads with restrictions. The specific criteria are: The bucket is mostly private and requires my key/secret to add/remove/update/list…
Eric Anderson
  • 3,692
  • 4
  • 31
  • 34
17
votes
3 answers

Linkage of symbols within anonymous namespace within a regular namespace

In C++, putting a function or a variable in an anonymous namespace makes its linkage internal, i. e. the same as declaring it static on a file-level, but idiomatic C++. What about an anonymous namespace within a normal namespace? Does it still…
Alex B
  • 82,554
  • 44
  • 203
  • 280
17
votes
2 answers

Send anonymous mail from local machine

I was using Python for sending an email using an external SMTP server. In the code below, I tried using smtp.gmail.com to send an email from a gmail id to some other id. I was able to produce the output with the code below. import smtplib from…
Nidhin Joseph
  • 1,461
  • 3
  • 15
  • 32
17
votes
3 answers

Passing an anonymous object as an argument in C#

I have a problem with passing an anonymous object as an argument in a method. I want to pass the object like in JavaScript. Example: function Test(obj) { return obj.txt; } console.log(Test({ txt: "test"})); But in C#, it throws many…
user1091156
  • 239
  • 1
  • 2
  • 8
14
votes
16 answers

Office documents prompt for login in anonymous SharePoint site

I have a MOSS 07 site that is configured for anonymous access. There is a document library within this site that also has anonymous access enabled. When an anonymous user clicks on a PDF file in this library, he or she can read or download it with…
xmt15
14
votes
3 answers

What if I need anonymous namespace in a header?

In C++ an anonymous namespace is equivalent to: namespace $$$$ { //something } using namespace $$$$; Where $$$$ is some kind of unique identifier. Anonymous namespace are then useful for code that should not be seen outside the compilation…
Paolo.Bolzoni
  • 2,416
  • 1
  • 18
  • 29
13
votes
4 answers

Anonymous class construction

I need an idea to create anonymous class on PHP. I don't know how I can works. See my limitations: On PHP you can't make anonymous class, like anonymous function (like class {}); On PHP you don't have class scope (except in namespaces, but it have…
David Rodrigues
  • 12,041
  • 16
  • 62
  • 90
13
votes
2 answers

Why not to allow in-place interface implementation in .NET?

Either I am missing something or .NET doesn't support what Java does. I'd like to be able to avoid creating a small class just for the sake of implementing a small interface. For example, LINQ's Except method expects IEqualityComparer. So I had to…
Schultz9999
  • 8,717
  • 8
  • 48
  • 87
13
votes
8 answers

lambda returns lambda in python

Very rarely I'll come across some code in python that uses an anonymous function which returns an anonymous function...? Unfortunately I can't find an example on hand, but it usually takes the form like this: g = lambda x,c: x**c lambda c: c+1 Why…
HEXbutler
  • 131
  • 1
  • 4
13
votes
4 answers

Is there a way to concat C# anonymous types?

For example var hello = new { Hello = "Hello" }; var world = new { World = "World" }; var helloWorld = hello + world; Console.WriteLine(helloWorld.ToString()); //outputs {Hello = Hello, World = World} Is there any way to make this work?
Matthew T.
  • 131
  • 1
  • 3
1
2
3
46 47