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
9
votes
3 answers

How to terminate anonymous threads in Delphi on application close?

I have a Delphi application which spawns 6 anonymous threads upon some TTimer.OnTimer event. If I close the application from the X button in titlebar Access Violation at address $C0000005 is raised and FastMM reports leaked TAnonymousThread…
Gad D Lord
  • 6,620
  • 12
  • 60
  • 106
8
votes
1 answer

Restrict access to functionality for user by IP address

I have a website that allows a functionality for any user but each user is only allowed to use it a fixed amount of times. Allow me to go into some more detail, our "anonymous/guest" user is allowed to search on the database for entries only 3 times…
Dan Hanly
  • 7,829
  • 13
  • 73
  • 134
8
votes
3 answers

C# delegate compiler optimisation

I have started to use anonymous delegates a lot in C# and I have begun to wonder how efficient the complier or runtime is in removing them from the code that is actually run and I haven't seen this detailed anywhere? Is it clever enough at all to…
iam
  • 1,623
  • 1
  • 14
  • 28
8
votes
1 answer

Invoking Actions from Moq

I've got a service with a method that takes two Actions, one for success and one for failure. Each Action takes a Result parameter that contains additional information... void AuthoriseUser(AuthDetails loginDetails, Action onSuccess,…
GoatInTheMachine
  • 3,583
  • 3
  • 25
  • 35
8
votes
2 answers

Best way to Migrate Anonymous Profile

Is there an alternate way that migrates all parameters implicit? Or any other advantages. From MSDN: public void Profile_OnMigrateAnonymous(object sender, ProfileMigrateEventArgs args) { ProfileCommon anonymousProfile =…
Thomas Sandberg
  • 943
  • 2
  • 9
  • 19
7
votes
2 answers

Create an anonymous type from reflection ParamInfo[]

i want to create an anonymous type inside a function, when the anonymous type properties are the function parameters. for example, for the function: private bool CreatePerson(string FirstName, string LasName, int Age, int height); i will have an…
Rodniko
  • 4,926
  • 20
  • 69
  • 93
7
votes
3 answers

Can you create anonymous code blocks in Lua?

In programming languages such as C you can create an anonymous code block to limit the scope of variables to inside the block can the same be done with Lua? If so what would be the Lua equivalent of the following C code? void function() { { …
Puddler
  • 2,619
  • 2
  • 17
  • 26
7
votes
4 answers

Anonymous initialization of class with protected constructor

Let's assume we have a class: public class SomeClass { protected SomeClass () { } } In MainClass located in different package I tried to execute two lines: public static void main(String[] args) { SomeClass sac1 = new SomeClass();…
Tinki
  • 1,486
  • 1
  • 21
  • 32
7
votes
2 answers

Yii2 button onclick anonymous function

I am new to Yii2, and I am struggling to trigger an anonymous function by pressing a Yii2 button. Below are 6 samples, of which first two are OK. But that is not exactly what I wish to have. I would like to know how I can get an anonymous function…
7
votes
3 answers

Pass a function as parameter in jQuery?

I would like to pass to a jQuery function a regular function, instead of the usual anonymous function, but I'm not sure how such a thing could be done. Instead of this: function setVersion(feature) { $.post("some.php", { abc:"abc" }, …
thedp
  • 8,350
  • 16
  • 53
  • 95
7
votes
3 answers

Dynamically construct "or" LIKE query in LINQ to SQL

I have a LINQ query which is composed by an anonymous object. At a given point, I want to limit the results by incoming search parameters, but this can be one or more parameters, and I want to perform a "LIKE x OR LIKE y OR LIKE z" using those. In…
Maarten Ureel
  • 393
  • 4
  • 18
7
votes
1 answer

Which standards allow anonymous structs and unions in C and C++?

Where can we use anonymous structs and unions? struct { int bar; }; // anonymous struct union { int bar; }; // anonymous union I think that we can do it in the following standards: unions - C++98, C++03, C++11, C11 structs - C11 Am i…
FrozenHeart
  • 19,844
  • 33
  • 126
  • 242
7
votes
4 answers

Does the anonymous namespace enclose all namespaces?

In C++ you specify internal linkage by wrapping your class and function definitions inside an anonymous namespace. You can also explicitly instantiate templates, but to be standards conforming any explicit instantiations of the templates must occur…
Joseph Garvin
  • 20,727
  • 18
  • 94
  • 165
6
votes
3 answers

Anonymous variables (?) advantages?

I was wondering about one thing that jumped into my mind yesterday. I apologize in advance for the misleading title, but I really don't know how to entitle this. Well, suppose we are two objects ObjA and ObjB, and that, for instance, ObjB has a…
magicleon94
  • 4,887
  • 2
  • 24
  • 53
6
votes
2 answers

Accessing the variable inside anonymous namespace (c++)

I have following code and I don't know how can I access the x inside the anonymous namespace in this setting. Please tell me how? #include int x = 10; namespace { int x = 20; } int main(int x, char* y[]) { { int x = 30;…
RyanC
  • 189
  • 1
  • 9