Posts Tagged var args

C++ For C# Developers: Part 52 – Idioms and Best Practices

Tags: , , , , , , , ,

As a very large language used for a very wide range of purposes over many decades, C++ can be written in a lot of different ways. Today we’ll look at some of the norms for “modern” C++ to get a sense of how code is normally written.

Read the rest of this article »

6 Comments

C++ For C# Developers: Part 39 – Language Support Library

Tags: , , , ,

Some parts of C++ require parts of the C++ Standard Library. We’ve lightly touched on classes like std::initializer_list and std::typeinfo already, but today we’ll look at a whole lot more. We’ll see parts of the Standard Library that would typically be built into the language or are otherwise strongly tied to making use of particular language features.

Read the rest of this article »

4 Comments

C++ For C# Developers: Part 4 – Functions

Tags: , , , , ,

The series continues today with functions. These are obviously core to any programming language, but it’s not obvious how many ways they differ from functions in C#. From compile-time execution to automatic return value types, there are a lot of differences to cover today.

Read the rest of this article »

10 Comments

C++ Scripting: Part 24 – Default Parameters

Tags: , , , , ,

We’ve been able to call methods since the very beginning, but we’ve always had to pass all the parameters. Today we’ll add support for default parameters so you can skip them sometimes. There’s a surprising amount of detail involved with this, so read on to learn some caveats of C#, .NET, and C++.

Read the rest of this article »

No Comments

From AS3 to C#, Part 8: More Special Functions

Tags: , ,

Today we’ll continue talking about special types of functions in C#. Specifically, today’s article will cover indexers, explicit and implicit conversions, and variable numbers of arguments (“var args”).

Read the rest of this article »

1 Comment

Function Length

Tags: , , , , , ,

In my last article on getProperties, there was one strange finding in the tests of standard classes: the Function class seems to have a length field. What is it? Today we’ll see

Read the rest of this article »

4 Comments

Arguments Slowdown

Tags: , , ,

While I was working on last week’s article it became apparent that something strange was going on with the arguments keyword in AS3. Last week I showed that even after you’ve changed the parameters of a function, you can still get the original values by indexing into arguments. This implies a copy and a copy implies a slowdown. Read on to see if there really is a slowdown and, if there is, what kind of performance impact there is.

Read the rest of this article »

No Comments

Inlining Math Functions

Tags: , , , ,

As a followup to my article on Inlining Math.ceil(), I decided to inline some more functions in the Math class. Read on for the code as well as tests proving correctness and speed.

Read the rest of this article »

3 Comments

Var Args Is Slow

Tags: ,

Var args (a.k.a. …rest) is a useful feature introduced in AS3. Previously in AS2 (and JavaScript still), we were forced to pass an Array of arguments where an unlimited-length argument list would have been much natural. Unfortunately, this can be really slow. In this article I’ll show a much quicker way to pass unlimited arguments to functions.

Read the rest of this article »

2 Comments