Mutation - part 3: Aliased Mutability

Interior Mutability Aliased data We say that data is aliased / shared when it may be accessed from multiple variables or places: a static variable can be accessed from anywhere1 at anytime, and is thus always considered shared. a variable being borrowed with a & _ reference (hence my calling these references &shared _). a variable owned by a smart pointer offering Shared Ownership such as Rc or Arc.

Mutation - part 2: To mut or not to mut

CategoriesTeaching, Rust, Programming
Tagsrust C mutation variable meta programming globals
Prelude From the previous post: A (runtime) variable is a (static) binding to some place in memory, and is used to read/write from/into that place in memory Let’s illustrate it again with an example. The following code fn foo(){letx=42;lety=i32::wrapping_add(x,27)asu8;} unsugars to1: fn foo(){// allocate 4 bytes in the stack frame & bind at_x to its address letx: i32;// type inferred // allocate 1 byte in the stack frame & bind at_y to its address lety: u8;// type inferred *at_x=42;*at_y=i32::wrapping_add(*at_x,27)asu8;} So, whenever there is a variable var, the actual binding is from at_var to some address in memory, and var is just sugar for *at_var2.

Mutation - Part 1: Variables

CategoriesTeaching, Rust, Programming
Tagsrust C examples mutation variable meta programming
What is a variable? Ok, here there is really a lot that could be said, and a simple blog post will not cover it. I will just talk about two important and distinct thinking patterns involved: the idea of binding a name to a value; the idea of reading/writing values from/into memory; 1. Identity binding The best example in Rust for “just a binding” (i.e., with no backing memory) is const

Mutation - Part 0: Intro

CategoriesTeaching, Rust, Programming
Tagsrust C examples mutation variable meta programming
For a first programming post, I have chosen an innocent-looking topic, regarding Rust’s mut keyword: What does mut truly mean? what does it do? For starters, let’s quote TRPL1: Mutability, the ability to change something Hum, it looks like they got it the other way around. Let’s fix it: Mutability, the ability to change something Mutability, the property of being change-able Note the change in the grammatical aspect: if a mutator modifies a mutatee, the mutability required for it to be possible is the mutatee’s one (and not the mutator’s).

My first post ... and blog

CategoriesMeta, Introspection
Tagsmeta
git commit? It has been a while since I wanted to make the jump and dive into the publishing my thoughts and experiments to the World Wide Web experience. However, the most likely outcome is that I be its only reader. But I’d be content with that. Still, I do believe that some of my tinkering and experimentation could be of interest for other like-minded people. I (would?) like to think it is the main reason of my going public.