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
155
votes
1 answer

Modify a globally scoped variable inside of an anonymous function

I was playing around with anonymous functions in PHP and realized that they don't seem to reach variables outside of them. Is there any way to get around this problem? Example: $variable = "nothing"; functionName($someArgument, function() { …
einord
  • 2,278
  • 2
  • 20
  • 26
142
votes
5 answers

How to create an instance of anonymous interface in Kotlin?

I have a third party Java library which an object with interface like this: public interface Handler { void call(C context) throws Exception; } How can I concisely implement it in Kotlin similar to Java anonymous class like…
Peter Lamberg
  • 8,151
  • 3
  • 55
  • 69
77
votes
10 answers

WCFTestClient The HTTP request is unauthorized with client authentication scheme 'Anonymous'

I've created one WCF service and deployed it on Server. When I browse this service it gives me positive response with ?wsdl URL. Now I'm trying to test the service through WCF Test client. It shows proper metadata. But when I try to invoke any of…
user82613
  • 1,323
  • 2
  • 12
  • 17
70
votes
10 answers

How to compile C code with anonymous structs / unions?

I can do this in c++/g++: struct vec3 { union { struct { float x, y, z; }; float xyz[3]; }; }; Then, vec3 v; assert(&v.xyz[0] == &v.x); assert(&v.xyz[1] == &v.y); assert(&v.xyz[2] == &v.z); will…
solinent
  • 1,605
  • 1
  • 17
  • 19
49
votes
10 answers

How to contribute on github anonymously via Tor?

I would like to contribute anonymously to projects on github. Not to cause mischief, more in the spirit of anonymous donations. The tool of choice for being anonymous online seems to be TOR, which works well for almost anything you can do in a…
Greg Manitoba
  • 507
  • 1
  • 4
  • 4
38
votes
2 answers

Setting anonymous type property name

Let's say I have the following piece of code: string SomeConst = "OtherName"; var persons = GetPersons(); //returns list of Person var q = persons.Select(p => new { SomeConst = p.Name }); Basically I'd expect to have in q sequence of anonymous…
user759141
  • 577
  • 1
  • 6
  • 11
29
votes
2 answers

C++11 anonymous union with non-trivial members

I'm updating a struct of mine and I was wanting to add a std::string member to it. The original struct looks like this: struct Value { uint64_t lastUpdated; union { uint64_t ui; int64_t i; float f; bool b; }; }; Just adding…
OmnipotentEntity
  • 16,531
  • 6
  • 62
  • 96
28
votes
9 answers

Where do I put constant strings in C++: static class members or anonymous namespaces?

I need to define some constant strings that will be used only by one class. It looks like I have three options: Embed the strings directly into locations where they are used. Define them as private static constant members of the class: //A.h …
stone
  • 293
  • 1
  • 3
  • 6
28
votes
2 answers

In Java, can anonymous classes extend another class?

Code like: protected Interface1 varClass1 = new Interface1() { But I would also like that this anonymous nested class also extends the class Base, something like: protected Interface1 varClass1 = new Interface1() extends Base { .... Is this…
user810430
  • 11,181
  • 15
  • 38
  • 43
27
votes
6 answers

How to use c union nested in struct with no name

I'm working on the so called Hotspot open source project, and looking at the implementation I found a nasty nested union in struct looking like that: typedef struct RC_model_t_st { union { struct block_model_t_st *block; …
zwx
  • 315
  • 1
  • 4
  • 7
22
votes
4 answers

What is the difference between anonymous and inline functions in JavaScript?

The title sums up my question. An example that demonstrates the point would be nice.
matori82
  • 3,669
  • 9
  • 42
  • 64
21
votes
3 answers

initialization of anonymous structures or unions in C1X

I have the following question: How are anonymous structures (or unions) properly initialized according to the current C1X draft? Is this legal: struct foo { int a; struct { int i; int j; }; int b; }; struct foo f = {…
jmuc
  • 1,551
  • 1
  • 14
  • 16
21
votes
4 answers

ORA-06508: PL/SQL: could not find program unit being called

I am using oracle 10g and toad 11.5. I am trying to call an api from an anonymous block. If I recompile the api after adding dbms_output.put_line and then try to execute the anonymous block, it shows error as: "ORA-06508: PL/SQL: could not find…
battech
  • 803
  • 2
  • 13
  • 25
20
votes
4 answers

Why is the type of this function (a -> a) -> a?

Why is the type of this function (a -> a) -> a? Prelude> let y f = f (y f) Prelude> :t y y :: (t -> t) -> t Shouldn't it be an infinite/recursive type? I was going to try and put into words what I think it's type should be, but I just can't do it…
TheIronKnuckle
  • 7,224
  • 4
  • 33
  • 56
19
votes
7 answers

Why would I use Perl anonymous subroutines instead of a named one?

I'm just curious why one would choose to use an anonymous subroutine, versus a named one, in Perl. Thanks.
user102881
  • 191
  • 1
  • 1
  • 3
1
2 3
46 47