avatarDr. Derek Austin 🥳

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

5582

Abstract

alcoholics, for reasons yet obscure, have lost the power of choice in drink. Our so-called will power becomes practically nonexistent. We are unable, at certain times, to bring into our consciousness with sufficient force the memory of the suffering and humiliation of even a week or a month ago. We are without defense against the first drink.</p></blockquote><blockquote id="b97c"><p>~ The Big Book, page 24.</p></blockquote><p id="2733">I mumbled something about doing more therapy sessions to stay in touch with my baseline feelings, but my new sponsor was having none of it.</p><p id="e1c9">‘This isn’t an emotional issue!’ he said, cutting in. ‘This is a memory issue that no amount of therapy you chose to throw money at will solve.’</p><p id="1800">He even suggested that the mental blank spot could be similar to a form of amnesia or dementia that science hasn’t picked up on yet.</p><p id="4ad6">‘But why hasn’t science picked up on it?’ I asked, holding the phone tightly.</p><p id="26fb">‘Probably because this blank spot only happens at certain times. Most of the time, it lays dormant.’ he replied before warning,</p><p id="337a">‘And unfortunately, this dormancy feature gives us an illusion of power. We think we’ve got sobriety now because our memory and willpower function normally again. Until, the condition randomly comes back online, and we relapse, leaving us totally baffled as to why it happened.’</p><p id="a3e9">My new sponsor sighed deeply.</p><p id="f455">‘It’s heartbreaking,’ he said softly. ‘Especially if you’ve relapsed after being multiple years clean. But it is sadly needed to show you that you are genuinely powerless, regardless of how much you desire and want to be sober.’</p><p id="969d">My head was spinning. Every sentence felt like the jolt of an electric cattle prod.</p><p id="8e0a">Later that day, I looked back at my recent relapses. I found no real conscious memory of consequences before any of them.</p><p id="352f">It appeared relapse was happening to me, not by me.</p><blockquote id="8aba"><p>As soon as I regained my ability to think, I went carefully over that evening in Washington. Not only had I been off guard, I had made no fight whatever against the first drink. This time I had not thought of the consequences at all. I had commenced to drink as carelessly as though the cocktails were ginger ale. I now remembered what my alcoholic friends had told me, how they prophesied that if I had an alcoholic mind, the time and place would come — I would drink again. They had said that though I did raise a defense, it would one day give way before some trivial reason for having a drink. Well, just that did happen and more, for what I had learned of alcoholism did not occur to me at all. I knew from that moment that I had an alcoholic mind. I saw that will power and self-knowledge would not help in those strange mental blank spots. I had never been able to understand people who said that a problem had them hopelessly defeated. I knew then. It was a crushing blow.</p></blockquote><blockquote id="93f7"><p>~ The Big Book, page 41.</p></blockquote><figure id="7922"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/0*n4r4HuNFWSnCD_WU"><figcaption>Photo by <a href="https://unsplash.com/@alicealinari?utm_source=medium&amp;utm_medium=referral">Alice Alinari</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h2 id="287c">A Belief That It Will All Be Alright.</h2><p id="baea">Sadly, the ‘blank spot’ wasn’t all that was happening.</p><p id="7c3e">My new sponsor later explained that something else was happening in my mind, a kind of twisting of my thinking that I couldn’t see either.</p><p id="02a0">This is the other main feature of the relapse condition.</p><p id="da70">The Big Book explains it as follows:</p><blockquote id="f067"><p>But there was always the curious mental phenomenon that parallel with our sound reasoning, there inevitably ran some insanely trivial excuse for taking the first drink. Our sound reasoning failed to hold us in check. The insane idea won out.</p></blockquote><blockquote id="4ad8"><p>~ The Big Book, page 37.</p></blockquote><p id="da58">Anytime the ‘good idea’ of relapsing suddenly popped into my head, part of me would start to minimise the lunacy of this thought.</p><p id="e2c7">I would begin to rationalise this catastrophic idea with excuses and reasons why it would be, in fact, okay to relapse despite being in recovery.</p><p id="432a">No matter how insignificant and non-sensical those reasons were, they quickly became plausible and seemingly rational.</p><p id="6997">At the same time, the urge to want to relapse would start to surge.</p><p id="cdc4">A fear of missing out would relentlessly come crashing in like waves rolling in and out of my consciousness.</p><p id="b225">Thoughts and narratives of why it would be okay this time would dominate my thinking.</p><p id="fe2d">Finally, a tidal wave of justification would smother me into deep unconsciousness.</p><p id="c65b">Convinced of my rationale, I would carry out my plan, only to revert back to type and do everything I said I wouldn’t do, and again, find myself powerless to stop once I started.</p><p id="34a2">This twisted thinking was nothing more than a lie, but I believed the lie and didn’t see the flaw in the logic in light of my track record with partying.</p><p id="888a">To any average person, this kind of thinking and decision-making would be termed irrational, unsound, or even insa

Options

ne.</p><p id="d880">The Big Book calls this thinking an <i>‘obsession to beat the game’</i>.</p><p id="9087">Whether it’s a vague idea that this time it would be different, that I would do it differently and party like a gentleman.</p><p id="b075">Or the well-loved excuse that this will be my last relapse. After this final time, I’ll be done for good. I’ll get on with my life.</p><p id="be67">But, it never was different and that last time never did happen.</p><p id="149d">My new sponsor would remind me often,</p><p id="a62b" type="7">‘You aren’t changing your mind when you’ve decided to give in and party; your mind has been changed for you.’</p><h2 id="4c19">It Centers In Our Minds</h2><p id="f0e7">Of course, there is a body element for the addict.</p><p id="86b6">Naturally, as a consequence of the constant extreme usage of powerfully addictive substances and processes that are designed by their very nature to make you want more and more, addicts have developed a sky-high tolerance.</p><p id="2d70">But there’s this annihilation approach to our acting out and using once we start, which the Big Book describes as the <i>‘phenomenon of craving’</i>.</p><p id="01c2">In the Doctor’s opinion in the Big Book, Dr. Silkworth calls the phenomenon of craving an ‘allergy’, but my new sponsor wasn’t too keen on that idea.</p><p id="10af" type="7">‘If it’s an allergy, then why doesn’t the phenomenon of craving happen every time?’</p><p id="ae75">Regardless of whether it is an allergy, the body part becomes irrelevant, as most people with a severe peanut allergy don’t tend to keep repeating the total lost cause of trying to have another peanut to see if they will react differently.</p><p id="2e48">They don’t touch or go anywhere near peanuts because they remember how terrible it was last time.</p><p id="436a">Once or twice is enough.</p><p id="3796">Not so with the real addict because of the first two features of the disease; they will not only be back gorging on peanuts, but they will eventually take up residence in a peanut factory.</p><blockquote id="e3f6"><p>There is a complete failure of the kind of defence that keeps one from putting his hand on a hot stove. The alcoholic may say to himself in the most casual way, “It won’t burn me this time, so here’s how!” Or perhaps he doesn’t think at all.</p></blockquote><blockquote id="d5e6"><p>~ The Big Book, page 24.</p></blockquote><p id="5cb9">That’s why the Big Book says the real problem ‘centers in our mind’, not our bodies.</p><p id="22d4">‘What will happen now,’ my new sponsor forewarned, ‘as the relapses get worse, the time between them will get shorter and shorter.’</p><p id="6f0b">This condition is progressive.</p><p id="e8f1">Therefore, the blanking and twisting will naturally grow in scope and reach until you can no longer differentiate the true from the false.</p><h2 id="869b">Turning To Something Else</h2><p id="922a">If you believe in the disease concept of addiction, that this is a disease, a fatal illness precisely like any other life-threatening condition, then you have it for life.</p><p id="a2d8">There is <b>nothing </b>you can do to change that.</p><p id="d5f6">If you constantly can’t remember why or how you relapsed despite your honest desire not to.</p><p id="9aaf">Or if you continually relapse, believing some trivial reason or silly excuse to relapse while dismissing the genuine consequences, then you are a real addict.</p><p id="a47a">You have this relapse condition.</p><p id="840d">You <b>crossed a threshold </b>where, at certain times, your inability to use reasoning and rational thinking won’t even register for you.</p><p id="d8c6">The tragic truth is that once that threshold has been crossed, you have <b>no choice</b> but to relapse.</p><p id="0564">A compromised part of your brain will always fire the thought of using or acting out. That will never change. It’s wired like that for life.</p><p id="5fb0">There is no cure.</p><p id="fcca">Even this information won’t save you, as at certain times, you won’t be able to recall any of it when it matters.</p><p id="7fc5">So, let go of trying to change that.</p><p id="59f9">Let go of any old ideas around fighting it and instead get out of the way and <b>trust in something else</b>.</p><p id="b722">After all, that’s all you’ve got.</p><p id="5065">There’s nothing you or anyone else can do to stop this relapse condition.</p><p id="d1dd">But there’s everything you can do about everything else.</p><p id="5e51">There’s everything you can do about building a <b>spiritual dimension</b> to your life, by giving back, helping others, living in genuine faith and trusting in something greater than you.</p><p id="3096">There’s everything you can do to improve your awareness and intuition, raise your consciousness and develop another part of your brain.</p><p id="7598">And let this part of your brain grow bigger and stronger than that addictive part so that it can embrace and look after that compromised part.</p><p id="d2e3">Just like a bigger and wiser older sibling can care for and comfort a much younger upset sibling by giving that stressed child a big hug.</p><p id="da93">There’s everything you can do about deciding to take on a new attitude, direction, and way of life that will keep this condition dormant one day at a time.</p><p id="e415">If this article speaks to you, please follow, share and subscribe to me for more.</p><p id="fc50">Click <a href="https://twitter.com/TheDarrenJames">here</a> to follow me on <a href="https://twitter.com/TheDarrenJames">X</a>.</p></article></body>

How To Use Readonly in TypeScript

Exploring the power of built-in utility types for safer code

Is it that a clock is Readonly, or that only a broken clock is Readonly? Photo by Mpho Mojapelo on Unsplash

TypeScript has introduced a variety of utility types, designed to help transform and manipulate types in more advanced ways, allowing developers to write safer and more robust code. One of these powerful utility types is Readonly<Type>. In this article, we’ll take a deep dive into Readonly and see how it can supercharge your TypeScript experience.

What Is Readonly?

The Readonly utility type, released with TypeScript 2.1, constructs a type with all properties of Type set to readonly. This means the properties of the constructed type cannot be reassigned.

Consider the following code:

type Todo = {
  title: string;
}
 
const todo: Readonly<Todo> = {
  title: "Delete inactive users",
}
 
todo.title = "Hello"

// Error: Cannot assign to 'title' because it is a read-only property.

In the example above, we have a Todo type with a single property title. We then create an object todo, of type Readonly<Todo>. As a result, TypeScript ensures that the properties of todo cannot be reassigned after initialization, enforcing immutability at the type level.

This utility is particularly useful for representing assignment expressions that would fail at runtime, such as when attempting to reassign properties of a frozen object.

Practical Use Case: The Power of Immutability

Let’s say you’re building a function that accepts a configuration object. This function is used across your codebase, and to prevent bugs, you want to ensure that this configuration object is not accidentally mutated inside the function.

Consider the following example:

interface Config {
  apiUrl: string;
  timeout: number;
}

function performRequest(config: Config) {
  // ... perform some request
}

const config: Config = {
  apiUrl: "https://api.example.com",
  timeout: 5000
}

performRequest(config)

In this code, there’s nothing stopping performRequest from modifying the config object. To ensure config remains unchanged, we can use the Readonly utility type:

function performRequest(config: Readonly<Config>) {
  // ... perform some request
  // config.apiUrl = "https://api.other.com"; // Error: Cannot assign to 'apiUrl' because it is a read-only property.
}

Now, TypeScript will throw an error if we try to modify the config object inside performRequest, preventing possible bugs and making our code safer.

Comparing Readonly and “as const”

TypeScript offers developers a variety of tools to help ensure data immutability. Two such tools are Readonly and as const. Although they can be used interchangeably in some scenarios, they are fundamentally different and each has its own unique use cases.

Understanding Readonly

Readonly is a utility type provided by TypeScript. It creates a type that has all the same properties as the input type, but each property is marked as readonly. This effectively means that you cannot reassign the properties of an object of this type once it's been created.

Here’s a simple example of how it works:

type Person = {
  name: string;
  age: number;
}

const john: Readonly<Person> = {
  name: "John",
  age: 30,
}

john.age = 31

// Error: Cannot assign to 'age' because it is a read-only property.

In the example above, john is of type Readonly<Person>, which means all of its properties are readonly. Attempting to reassign any of these properties results in a TypeScript error.

The Power of “as const”

as const is a little more complex. It is not a type, but a type assertion. When you use as const, you're telling TypeScript that you want the narrowest possible type to be inferred for your variable. This means:

  1. Variables are inferred to be of a literal type, not a broader type.
  2. Object properties are inferred as readonly.
  3. Arrays are inferred to be readonly tuples.

Here’s an example to illustrate:

const john = {
  name: "John",
  age: 30,
} as const

john.age = 31

// Error: Cannot assign to 'age' because it is a read-only property.

In this example, john is inferred to be of a type that has readonly properties name and age, with specific literal values "John" and >30. This means you cannot change the properties once they're assigned, similar to Readonly.

For this reason, I tend to get these concepts mixed up in my head.

However, the difference is that as const also affects variables and arrays, not just the properties of objects:

const age = 30 as const;

age = 31

// Error: Cannot assign to 'age' because it is a read-only property.

In this example, age is inferred to be of type 30, not number. Attempting to change its value results in a TypeScript error.

const numbers = [1, 2, 3] as const

numbers.push(4)

// Error: Property 'push' does not exist on type 'readonly [1, 2, 3]'.

Here, numbers is inferred to be a readonly tuple of [1, 2, 3], not an array of number[]. This means you can't modify the array using methods like push, or you’ll get an error that the array method only doesn’t exist.

When to Use Readonly vs “as const”

Use Readonly when you want to create a type where all properties of an object are readonly. It’s particularly useful when creating interfaces or types that will be used across your codebase to enforce immutability.

Use as const when you want the narrowest type to be inferred for a variable, whether it's a single variable, an array, or an object. It's most useful when you're declaring constants or configuration objects where the values and structure won't change.

Remember, as const is a type assertion, so it won't create a new type that you can use elsewhere in your code. If you need to reuse a readonly type in multiple places, it’s better to create a Readonly type or interface.

To summarize, Readonly and as const are powerful tools in TypeScript for enforcing immutability. While Readonly is a utility type that makes all properties of an object readonly, as const is a type assertion that infers the narrowest possible type for a variable, making variables, object properties, and arrays readonly. Therefore, the choice between the two will largely depend on your specific use case.

Consider the following scenarios:

  1. If you are working with an object and want to prevent its properties from being modified, both Readonly and as const can be used. But if the object type is to be reused in multiple places, Readonly is a better choice.
  2. For individual variables, especially when dealing with constant values, as const is the way to go as it infers a literal type, preventing any changes to the variable.
  3. If you are dealing with an array and want to prevent any modifications to it, as const should be used because it makes the array readonly and also infers it as a tuple with fixed length and types.

Ultimately, understanding the differences between Readonly and as const and their appropriate use cases will allow you to write more secure, predictable, and error-resistant TypeScript code.

Wrapping Up: Readonly CONSTANTS in TypeScript

The Readonly utility type is a powerful tool in TypeScript's utility type arsenal, allowing us to enforce immutability in our types and prevent bugs due to unwanted mutation. This is just one of many utility types available in TypeScript. Explore the TypeScript Docs to learn about more of these powerful tools.

Remember, TypeScript is not just about providing static types for JavaScript, but also about making your code safer, more readable, and easier to refactor. So next time you’re about to write a TypeScript function, think about how utility types like Readonly can be used to make your code safer and more robust.

Now this is a Readonly clock. { time: “II:XLII” } Photo by Elena Koycheva on Unsplash
Typescript
JavaScript
Software Development
Programming
Computer Science
Recommended from ReadMedium