Skip to content

Commit

Permalink
Merge branch 'master' into Issue3
Browse files Browse the repository at this point in the history
  • Loading branch information
vulder authored Oct 1, 2024
2 parents 5082bea + ab3c4be commit bf04222
Show file tree
Hide file tree
Showing 4 changed files with 196 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Collect git metadata
id: git_metadata
run: |
echo "{VERSION}::{${GITHUB_REF#refs/tags/v}}" >> $GITHUB_OUTPUT
echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
# The following builds the document in multiple formats for deployment.
- name: Build the document.
shell: bash
Expand Down
98 changes: 98 additions & 0 deletions sources/modules/functions/passing-parameters-by-reference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Module name: Passing Parameters by Reference
_Skeleton descriptions are typeset in italic text,_
_so please don't remove these descriptions when editing the topic._

## Overview

_Provides a short natural language abstract of the module’s contents._
_Specifies the different levels of teaching._

<table>
<thead>
<th>Level</th>
<th>Objectives</th>
</thead>
<tr>
<td>Foundational</td>
<td>Avoiding copies using const-reference modifiers</td>
</tr>
<tr>
<td>Main</td>
<td>Using references to modify external data</td>
</tr>
<tr>
<td>Advanced</td>
<td></td>
</tr>
</table>

## Motivation

_Why is this important?_
_Why do we want to learn/teach this topic?_

## Topic introduction

_Very brief introduction to the topic._

Explain what a reference type is and how it constrasts with a value type.

## Foundational: Using reference types to avoid copies

### Background/Required Knowledge

A student is able to:

* Define and call a function with parameters

### Student outcomes

_A list of things "a student should be able to" after the curriculum._
_The next word should be an action word and testable in an exam._
_Max 5 items._

A student should be able to:

1. Use const-refernce types for function arguments
2. Explain what considerations to take when deciding whether or not to use a const-reference type

### Caveats

_This section mentions subtle points to understand, like anything resulting in
implementation-defined, unspecified, or undefined behavior._

### Points to cover

_This section lists important details for each point._

* No copy of the data is made when taken by constant reference
* A constant reference value cannot be modified
* The lifetime of a constant reference cannot be expected to extend beyond the lifetime of the function, so the reference should not be saved off for future use.
* Taking a reference is not always a time or space savings. Modern machines may use 8-bytes to reference a 4-byte integer, for instance.

## Main: Using references to modify external data

### Background/Required Knowledge

* All of the above

### Student outcomes

A student should be able to:

1. Define and utilize a non-const reference for passing values out of a function

### Caveats

### Points to cover

* If the function does not intend to modify the value, const-references should be preferred
* A reference value may be modified
* The lifetime of a reference cannot be expected to extend beyond the lifetime of the function, so the reference should not be saved off for future use.
* Taking a reference is not always a time or space savings. Modern machines may use 8-bytes to reference a 4-byte integer, for instance.

## Advanced

_These are important topics that are not expected to be covered but provide
guidance where one can continue to investigate this topic in more depth._

91 changes: 91 additions & 0 deletions sources/modules/functions/passing-parameters-by-value.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Module name: Passing Parameters by Value
_Skeleton descriptions are typeset in italic text,_
_so please don't remove these descriptions when editing the topic._

## Overview

_Provides a short natural language abstract of the module’s contents._
_Specifies the different levels of teaching._

<table>
<thead>
<th>Level</th>
<th>Objectives</th>
</thead>
<tr>
<td>Foundational</td>
<td>Defining and calling functions with values</td>
</tr>
<tr>
<td>Main</td>
<td></td>
</tr>
<tr>
<td>Advanced</td>
<td></td>
</tr>
</table>

## Motivation

_Why is this important?_
_Why do we want to learn/teach this topic?_

The fundamental element for code-reuse is a function. For functions to be
useful, we need to parameterize them. Understanding how to do such is thus
fundamental to programming in any language.

## Topic introduction

_Very brief introduction to the topic._

Explain how to define functions with parameters and call them with values.

## Foundational: Using reference types to avoid copies

### Background/Required Knowledge

A student is able to:

* Explain what a function is

### Student outcomes

_A list of things "a student should be able to" after the curriculum._
_The next word should be an action word and testable in an exam._
_Max 5 items._

A student should be able to:

1. Call a function with any number of parameters using the same number of arguments
2. Define a function with any number of parameters

### Caveats

_This section mentions subtle points to understand, like anything resulting in
implementation-defined, unspecified, or undefined behavior._

### Points to cover

_This section lists important details for each point._

* A function is called by invoking the name of the function, followed by parentheses
* For each parameter in the function signature, a value must be provided, and in the same order
* Multiple values passed to a function are comma-separated
* When defining a function, you must list the parameters with the type first, and parameter name second

## Main: Using references to modify external data

### Background/Required Knowledge

### Student outcomes

### Caveats

### Points to cover

## Advanced

_These are important topics that are not expected to be covered but provide
guidance where one can continue to investigate this topic in more depth._

7 changes: 6 additions & 1 deletion sources/modules/functions/user-defined-literals.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Functions: user-defined literals {#udl}
## Functions: user-defined literals (UDL) {#udl}

_Skeleton descriptions are typeset in italic text,_
_so please don't remove these descriptions when editing the topic._
Expand All @@ -8,6 +8,11 @@ _so please don't remove these descriptions when editing the topic._
_Provides a short natural language abstract of the module’s contents._
_Specifies the different levels of teaching._

Literals are a way to write values in the code, such as strings and numbers.
User-defined literals (UDL) allow to add a suffix to a string or number to change the meaning.
The suffix selects a function (an operator) that can alter the value and type of the literal.
The C++ library provides certain operators already and a user can add more by providing such operators.

-------------------------------------------------------------------------
Level Objectives
---------------- --------------------------------------------------------
Expand Down

0 comments on commit bf04222

Please sign in to comment.