100% found this document useful (2 votes)
22 views62 pages

Programming Kotlin Applications Building Mobile and Server Side Applications With Kotlin 1st Edition Brett Mclaughlin

The document provides a collection of eBooks available for download at textbookfull.com, focusing on programming with Kotlin and related technologies. It includes titles such as 'Programming Kotlin Applications' and 'Kotlin Apprentice,' among others. Users can download eBooks in various formats and read them on any device at their convenience.

Uploaded by

penasonevjo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
22 views62 pages

Programming Kotlin Applications Building Mobile and Server Side Applications With Kotlin 1st Edition Brett Mclaughlin

The document provides a collection of eBooks available for download at textbookfull.com, focusing on programming with Kotlin and related technologies. It includes titles such as 'Programming Kotlin Applications' and 'Kotlin Apprentice,' among others. Users can download eBooks in various formats and read them on any device at their convenience.

Uploaded by

penasonevjo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 62

Explore the full ebook collection and download it now at textbookfull.

com

Programming Kotlin Applications Building Mobile


and Server Side Applications with Kotlin 1st
Edition Brett Mclaughlin

https://textbookfull.com/product/programming-kotlin-
applications-building-mobile-and-server-side-applications-
with-kotlin-1st-edition-brett-mclaughlin/

OR CLICK HERE

DOWLOAD EBOOK

Browse and Get More Ebook Downloads Instantly at https://textbookfull.com


Click here to visit textbookfull.com and download textbook now
Your digital treasures (PDF, ePub, MOBI) await
Download instantly and pick your perfect format...

Read anywhere, anytime, on any device!

Kotlin Apprentice Second Edition Beginning Programming


with Kotlin Irina Galata

https://textbookfull.com/product/kotlin-apprentice-second-edition-
beginning-programming-with-kotlin-irina-galata/

textbookfull.com

Building web and mobile ArcGIS Server applications with


JavaScript Lewin

https://textbookfull.com/product/building-web-and-mobile-arcgis-
server-applications-with-javascript-lewin/

textbookfull.com

Programming Kotlin Create Elegant Expressive and


Performant JVM and Android Applications 1st Edition Venkat
Subramaniam
https://textbookfull.com/product/programming-kotlin-create-elegant-
expressive-and-performant-jvm-and-android-applications-1st-edition-
venkat-subramaniam/
textbookfull.com

Building React Apps with Server Side Rendering Use React


Redux and Next to Build Full Server Side Rendering
Applications Thakkar Mohit
https://textbookfull.com/product/building-react-apps-with-server-side-
rendering-use-react-redux-and-next-to-build-full-server-side-
rendering-applications-thakkar-mohit/
textbookfull.com
Building React Apps with Server Side Rendering Use React
Redux and Next to Build Full Server Side Rendering
Applications Thakkar Mohit
https://textbookfull.com/product/building-react-apps-with-server-side-
rendering-use-react-redux-and-next-to-build-full-server-side-
rendering-applications-thakkar-mohit-2/
textbookfull.com

Spring Boot: Up and Running: Building Cloud Native Java


and Kotlin Applications Mark Heckler

https://textbookfull.com/product/spring-boot-up-and-running-building-
cloud-native-java-and-kotlin-applications-mark-heckler/

textbookfull.com

Programming Kotlin Enhance your skills for Android


development using Kotlin 2nd Edition Alexander Aronowitz

https://textbookfull.com/product/programming-kotlin-enhance-your-
skills-for-android-development-using-kotlin-2nd-edition-alexander-
aronowitz/
textbookfull.com

Exploring Blazor: Creating Hosted, Server-side, and


Client-side Applications with C# Taurius Litvinavicius

https://textbookfull.com/product/exploring-blazor-creating-hosted-
server-side-and-client-side-applications-with-c-taurius-litvinavicius/

textbookfull.com

Programming Android With Kotlin: Achieving Structured


Concurrency With Coroutines Pierre-Olivier Laurence

https://textbookfull.com/product/programming-android-with-kotlin-
achieving-structured-concurrency-with-coroutines-pierre-olivier-
laurence/
textbookfull.com
PROGRAMMING
KOTLIN® APPLICATIONS

INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxv

CHAPTER 1 Objects All the Way Down. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1


CHAPTER 2 It’s Hard to Break Kotlin. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
CHAPTER 3 Kotlin Is Extremely Classy. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
CHAPTER 4 Inheritance Matters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
CHAPTER 5 Lists and Sets and Maps, Oh My! . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
CHAPTER 6 The Future (in Kotlin) Is Generic . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
CHAPTER 7 Flying through Control Structures. . . . . . . . . . . . . . . . . . . . . . . . . . 147
CHAPTER 8 Data Classes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
CHAPTER 9 Enums and Sealed, More Specialty Classes . . . . . . . . . . . . . . . . . . . 203
CHAPTER 10 Functions and Functions and Functions. . . . . . . . . . . . . . . . . . . . . . 233
CHAPTER 11 Speaking Idiomatic Kotlin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
CHAPTER 12 Inheritance, One More Time, with Feeling. . . . . . . . . . . . . . . . . . . . 303
CHAPTER 13 Kotlin: The Next Step. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331

INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339
Programming Kotlin® Applications
Programming Kotlin® Applications
BUILDING MOBILE AND SERVER-SIDE
APPLICATIONS WITH KOTLIN

Brett McLaughlin
Copyright © 2021 by John Wiley & Sons, Inc., Indianapolis, Indiana

Published simultaneously in Canada

ISBN: 978-1-119-69618-6
ISBN: 978-1-119-69616-2 (ebk)
ISBN: 978-1-119-69621-6 (ebk)

Manufactured in the United States of America

No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means,
electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of
the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through
payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923,
(978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Permissions
Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online
at www.wiley.com/go/permissions.

Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect
to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including without
limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or promotional
materials. The advice and strategies contained herein may not be suitable for every situation. This work is sold with the
understanding that the publisher is not engaged in rendering legal, accounting, or other professional services. If professional
assistance is required, the services of a competent professional person should be sought. Neither the publisher nor the author
shall be liable for damages arising herefrom. The fact that an organization or Web site is referred to in this work as a citation
and/or a potential source of further information does not mean that the author or the publisher endorses the information the
organization or Web site may provide or recommendations it may make. Further, readers should be aware that Internet Web
sites listed in this work may have changed or disappeared between when this work was written and when it is read.

For general information on our other products and services please contact our Customer Care Department within the United
States at (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.

Wiley publishes in a variety of print and electronic formats and by print-on-demand. Some material included with standard
print versions of this book may not be included in e-books or in print-on-demand. If this book refers to media such as a CD
or DVD that is not included in the version you purchased, you may download this material at booksupport.wiley.
com. For more information about Wiley products, visit www.wiley.com.
Library of Congress Control Number: 2020947753

Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Programmer to Programmer, and related trade dress are
trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other
countries, and may not be used without written permission. Kotlin is a registered trademark of Kotlin Foundation. All other
trademarks are the property of their respective owners. John Wiley & Sons, Inc., is not associated with any product or
vendor mentioned in this book.
for Leigh, as always, my person
ABOUT THE AUTHOR

BRETT MCLAUGHLIN has been working and writing in the technology space for over 20 years. Today,
Brett’s focus is squarely on cloud and enterprise computing. He has quickly become a trusted name
in helping companies execute a migration to the cloud—and in particular Amazon Web Services—by
translating confusing cloud concepts into a clear executive-level vision. He spends his days working
with key decision makers who need to understand the cloud as well as leading and building teams of
developers and operators who must interact with the ever-changing cloud computing space. He has
most recently led large-scale cloud migrations for NASA’s Earth Science program and the RockCreek
Group’s financial platform. Brett is currently the Chief Technology Officer at Volusion, an ecommerce
platform provider.
ABOUT THE TECHNICAL EDITOR

JASON LEE is a software developer happily living in the middle of the heartland. He has over 23 years
of experience in a variety of languages, writing software running on mobile devices all the way up
to big iron. For the past 15+ years, he has worked in the Java/Jakarta EE space, working on applica-
tion servers, frameworks, and user-facing applications. These days, he spends his time working as a
backend engineer, primarily using Kotlin, building systems with frameworks like Quarkus and Spring
Boot. He is the author of Java 9 Programming Blueprints, a former Java User Group president, an
occasional conference speaker, and a blogger. In his spare time, he enjoys spending time with his wife
and two sons, reading, playing the bass guitar, and running. He can be found on Twitter at twitter
.com/jasondlee, and on his blog at jasondl.ee.
ACKNOWLEDGMENTS

I USED TO WATCH MOVIES AND STARE in amazement at the hundreds of names that scrolled by at
the end. How could so many people be involved in a single movie?
Then I wrote a book. Now I understand.
Carole Jelen is my agent at Waterside, and she replied to an email and picked up the phone at a time
when I really needed someone to help me find my way back into publishing. I’m incredibly grateful.
On the Wiley side, Brad Jones was more patient than he ever should have been. Thanks, Brad! Barath
Kumar Rajasekaran handled a million tiny details, and Pete Gaughan and Devon Lewis kept the train
on the tracks. Christine O’Connor handled production, and Jason Lee caught the technical mistakes
in the text that you wouldn’t want to stumble over. Seriously, Jason in particular made this a much
better book with his keen eye.
As usual, it’s an author’s family that pays the highest price. Long days, more than a few weekends and
evenings, and a constant support keep us going. My wife, Leigh, is the best, and my kids, Dean, Rob-
bie, and Addie, always make finishing one of these a joy.
Let’s do brunch, everyone! Mimosas and breakfast tacos are on me.

—Brett McLaughlin
CONTENTS

INTRODUCTION xxv

CHAPTER 1: OBJECTS ALL THE WAY DOWN 1

Kotlin: A New Programming Language 1


What Is Kotlin? 2
What Does Kotlin Add to Java? 3
Kotlin Is Object-Oriented 3
Interlude: Set Up Your Kotlin Environment 4
Install Kotlin (and an IDE) 4
Install IntelliJ 5
Create Your Kotlin Program 8
Compile and Run Your Kotlin Program 9
Fix Any Errors as They Appear 10
Install Kotlin (and Use the Command Line) 10
Command-Line Kotlin on Windows 10
Command-Line Kotlin on Mac OS X 11
Command-Line Kotlin on UNIX-Based Systems 12
Verify Your Command-Line Installation 12
Creating Useful Objects 13
Pass In Values to an Object Using Its Constructor 13
Print an Object with toString() 14
Terminology Update: Functions and Methods 15
Print an Object (and Do It with Shorthand) 15
Override the toString() Method 16
All Data Is Not a Property Value 17
Initialize an Object and Change a Variable 19
Initialize a Class with a Block 19
Kotlin Auto-Generates Getters and Setters 20
Terminology Update: Getters, Setters, Mutators, Accessors 20
Constants Can’t Change (Sort of) 21

CHAPTER 2: IT’S HARD TO BREAK KOTLIN 25

Upgrade Your Kotlin Class Game 25


Name a File According to Its Class 26
Contents

Organize Your Classes with Packages 27


Put Person in a Package 28
Classes: The Ultimate Type in Kotlin 31
Kotlin Has a Large Number of Types 31
Numbers in Kotlin 31
Letters and Things 32
Truth or Fiction 33
Types Aren’t Interchangeable (Part 1) 33
You Must Initialize Your Properties 34
Types Aren’t Interchangeable (Part 2) 35
You Can Explicitly Tell Kotlin What Type to Use 36
Try to Anticipate How Types Will Be Used 37
It’s Easy to Break Kotlin (Sort of) 37
Overriding Property Accessors and Mutators 37
Custom-Set Properties Can’t Be in a Primary Constructor 38
Move Properties Out of Your Primary Constructors 38
Initialize Properties Immediately 39
Try to Avoid Overusing Names 41
Override Mutators for Certain Properties 41
Classes Can Have Custom Behavior 43
Define a Custom Method on Your Class 43
Every Property Must Be Initialized 44
Assign an Uninitialized Property a Dummy Value 45
Tell Kotlin You’ll Initialize a Property Later 45
Assign Your Property the Return Value from a Function 46
Sometimes You Don’t Need a Property! 47
TYPE SAFETY CHANGES EVERYTHING 49
Writing Code Is Rarely Linear 49
CHAPTER 3: KOTLIN IS EXTREMELY CLASSY 51

Objects, Classes, and Kotlin 51


All Classes Need an equals(x) Method 52
Equals(x) Is Used to Compare Two Objects 52
Override equals(x) to Make It Meaningful 54
Every Object Is a Particular Type 56
A Brief Introduction to Null 58
Every Object Instance Needs a Unique hashCode() 59
All Classes Inherit from Any 59
Always Override hashCode() and equals(x) 61
Default Hash Codes Are Based on Memory Location 63
Use Hash Codes to Come Up with Hash Codes 63

xvi
Contents

Searching (and Other Things) Depend on Useful and Fast equals(x)


and hashCode() 64
Multiple Properties to Differentiate Them in hashCode() 65
Use == over equals(x) for Speed 66
A Quick Speed Check on hashCode() 66
Basic Class Methods Are Really Important 67

CHAPTER 4: INHERITANCE MATTERS 69

Good Classes Are Not Always Complex Classes 69


Keep It Simple, Stupid 70
Keep It Flexible, Stupid 71
Classes Can Define Default Values for Properties 73
Constructors Can Accept Default Values 74
Kotlin Expects Arguments in Order 74
Specify Arguments by Name 74
Change the Order of Arguments (If You Need) 75
Secondary Constructors Provide Additional Construction Options 76
Secondary Constructors Come Second 76
Secondary Constructors Can Assign Property Values 77
You Can Assign null to a Property . . . Sometimes 79
null Properties Can Cause Problems 81
Handle Dependent Values with Custom Mutators 82
Set Dependent Values in a Custom Mutator 82
All Property Assignments Use the Property’s Mutator 83
Nullable Values Can Be Set to null! 84
Limit Access to Dependent Values 86
When Possible, Calculate Dependent Values 87
You Can Avoid Parentheses with a Read-Only Property 88
Need Specifics? Consider a Subclass 91
Any Is the Base Class for Everything in Kotlin 91
{ . . . } Is Shorthand for Collapsed Code 93
A Class Must Be Open for Subclassing 94
Terminology: Subclass, Inherit, Base Class, and More 95
A Subclass Must Follow Its Superclass’s Rules 96
A Subclass Gets Behavior from All of Its Superclasses 96
Your Subclass Should Be Different Than Your Superclass 97
Subclass Constructors Often Add Arguments 97
Don’t Make Mutable What Isn’t Mutable 98
Sometimes Objects Don’t Exactly Map to the Real World 99
Generally, Objects Should Map to the Real World 99

xvii
Contents

CHAPTER 5: LISTS AND SETS AND MAPS, OH MY! 101

Lists Are Just a Collection of Things 101


Kotlin Lists: One Type of Collection 101
Collection Is a Factory for Collection Objects 102
Collection Is Automatically Available to Your Code 104
Mutating a Mutable List 105
Getting Properties from a Mutable List 105
Lists (and Collections) Can Be Typed 106
Give Your Lists Types 107
Iterate over Your Lists 108
Kotlin Tries to Figure Out What You Mean 111
Lists Are Ordered and Can Repeat 111
Order Gives You Ordered Access 112
Lists Can Contain Duplicate Items 112
Sets: Unordered but Unique 113
In Sets, Ordering Is Not Guaranteed 114
When Does Order Matter? 115
Sort Lists (and Sets) on the Fly 115
Sets: No Duplicates, No Matter What 116
Sets “Swallow Up” Duplicates 116
Sets Use equals(x) to Determine Existing Membership 116
Using a Set? Check equals(x) 119
Iterators Aren’t (Always) Mutable 119
Maps: When a Single Value Isn’t Enough 119
Maps Are Created by Factories 120
Use Keys to Find Values 120
How Do You Want Your Value? 121
Filter a Collection by . . . Anything 121
Filter Based on a Certain Criterion 122
Filter Has a Number of Useful Variations 123
Collections: For Primitive and Custom Types 123
Add a Collection to Person 124
Allow Collections to Be Added to Collection Properties 126
Sets and MutableSets Aren’t the Same 127
Collection Properties Are Just Collections 128

CHAPTER 6: THE FUTURE (IN KOTLIN) IS GENERIC 129

Generics Allow Deferring of a Type 129


Collections Are Generic 129
Parameterized Types Are Available Throughout a Class 130
Generic: What Exactly Does It Refer To? 131

xviii
Contents

Generics Try to Infer a Type When Possible 132


Kotlin Looks for Matching Types 132
Kotlin Looks for the Narrowest Type 132
Sometimes Type Inference Is Wrong 133
Don’t Assume You Know Object Intent 133
Kotlin Doesn’t Tell You the Generic Type 134
Just Tell Kotlin What You Want! 134
Covariance: A Study in Types and Assignment 134
What about Generic Types? 135
Some Languages Take Extra Work to Be Covariant 137
Kotlin Actually Takes Extra Work to Be Covariant, Too 137
Sometimes You Have to Make Explicit What Is Obvious 137
Covariant Types Limit the Input Type as Well as the Output Type 137
Covariance Is Really about Making Inheritance Work
the Way You Expect 138
Contravariance: Building Consumers from Generic Types 138
Contravariance: Limiting What Comes Out Rather
Than What Comes In 139
Contravariance Works from a Base Class Down to a Subclass 141
Contravariant Classes Can’t Return a Generic Type 141
Does Any of This Really Matter? 142
Unsafevariance: Learning The Rules,
then Breaking Them 142
Typeprojection Lets You Deal with Base Classes 143
Variance Can Affect Functions, Not Just Classes 143
Type Projection Tells Kotlin to Allow Subclasses
as Input for a Base Class 144
Producers Can’t Consume and Consumers Can’t Produce 145
Variance Can’t Solve Every Problem 145

CHAPTER 7: FLYING THROUGH CONTROL STRUCTURES 147

Control Structures Are the Bread and


Butter of Programming 147
If and Else: The Great Decision Point 148
!! Ensures Non-Nullable Values 148
Control Structures Affect the Flow of Your Code 149
if and else Follow a Basic Structure 150
Expressions and if Statements 151
Use the Results of an if Statement Directly 152
Kotlin Has No Ternary Operator 153
A Block Evaluates to the Last Statement in That Block 153
if Statements That Are Assigned Must Have else Blocks 154

xix
Contents

When Is Kotlin’s Version of Switch 154


Each Comparison or Condition Is a Code Block 155
Handle Everything Else with an else Block 156
Each Branch Can Support a Range 157
Each Branch Usually Has a Partial Expression 158
Branch Conditions Are Checked Sequentially 159
Branch Conditions Are Just Expressions 159
When Can Be Evaluated as a Statement, Too 160
For Is for Looping 161
For in Kotlin Requires an Iterator 162
You Do Less, Kotlin Does More 163
For Has Requirements for Iteration 163
You Can Grab Indices Instead of Objects with for 164
Use While to Execute until a Condition Is False 167
While Is All about a Boolean Condition 167
A Wrinkle in while: Multiple Operators, One Variable 168
Combine Control Structures for More Interesting Solutions 169
Do . . . While Always Runs Once 170
Every do . . . while Loop Can Be Written as a while Loop 170
If Something Must Happen, Use do . . . while 171
do . . . while Can Be a Performance Consideration 175
Get Out of a Loop Immediately with Break 176
Break Skips What’s Left in a Loop 176
You Can Use a Label with break 177
Go to the Next Iteration Immediately with Continue 178
Continue Works with Labels as Well 179
If versus continue: Mostly Style over Substance 179
Return Returns 180

CHAPTER 8: DATA CLASSES 183

Classes in the Real World Are Varied but


Well Explored 183
Many Classes Share Common Characteristics 183
Common Characteristics Result in Common Usage 185
A Data Class Takes the Work Out of a Class
Focused on Data 185
Data Classes Handle the Basics of Data for You 185
The Basics of Data Includes hashCode() and equals(x) 186
Destructuring Data through Declarations 188
Grab the Property Values from a Class Instance 188
Destructuring Declarations Aren’t Particularly Clever 189

xx
Contents

Kotlin Is Using componentN() Methods to Make Declarations Work 190


You Can Add componentN() Methods to Any Class 191
If You Can Use a Data Class, You Should 192
You Can “Copy” an Object or Make a Copy Of
an Object 192
Using = Doesn’t Actually Make a Copy 192
If You Want a Real Copy, Use copy() 193
Data Classes Require Several Things from You 194
Data Classes Require Parameters and val or var 194
Data Classes Cannot Be Abstract, Open, Sealed, or Inner 195
Data Classes Add Special Behavior to
Generated Code 195
You Can Override Compiler-Generated Versions of Many
Standard Methods 196
Supertype Class Functions Take Precedence 196
Data Classes Only Generate Code for Constructor Parameters 197
Only Constructor Parameters Are Used in equals() 199
Data Classes Are Best Left Alone 200

CHAPTER 9: ENUMS AND SEALED, MORE SPECIALTY CLASSES 203

Strings Are Terrible as Static Type Representations 203


Strings Are Terrible Type Representations 204
Capitalization Creates Comparison Problems 205
This Problem Occurs All the Time 206
String Constants Can Help . . . Some 206
Companion Objects Are Single Instance 207
Constants Must Be Singular 208
Companion Objects Are Singletons 209
Companion Objects Are Still Objects 210
You Can Use Companion Objects without Their Names 211
Using a Companion Object’s Name Is Optional 211
Using a Companion Object’s Name Is Stylistic 213
Companion Object Names Are Hard 214
You Can Skip the Companion Object Name Altogether 215
Enums Define Constants and Provide Type Safety 216
Enums Classes Provide Type-Safe Values 216
Enums Classes Are Still Classes 218
Enums Give You the Name and Position of Constants 219
Each Constant in an enum Is an Object 219
Each Constant Can Override Class-Level Behavior 220
Sealed Classes Are Type-Safe Class Hierarchies 221

xxi
Contents

Enums and Class Hierarchies Work for Shared Behavior 222


Sealed Classes Address Fixed Options and Non-Shared
Behavior 222
Sealed Classes Don’t Have Shared Behavior 223
Sealed Classes Have a Fixed Number of Subclasses 224
Subclasses of a Sealed Class Don’t Always Define Behavior 225
when Requires All Sealed Subclasses to Be Handled 225
when Expressions Must Be Exhaustive for Sealed Classes 226
else Clauses Usually Don’t Work for Sealed Classes 228
else Clauses Hide Unimplemented Subclass Behavior 229

CHAPTER 10: FUNCTIONS AND FUNCTIONS AND FUNCTIONS 233

Revisiting the Syntax of a Function 233


Functions Follow a Basic Formula 233
Function Arguments Also Have a Pattern 235
Default Values in Constructors Are Inherited 237
Default Values in Functions Are Inherited 238
Default Values in Functions Cannot Be Overridden 239
Default Values Can Affect Calling Functions 239
Calling Functions Using Named Arguments Is Flexible 241
Function Arguments Can’t Be Null Unless You Say So 241
Functions Follow Flexible Rules 243
Functions Actually Return Unit by Default 243
Functions Can Be Single Expressions 244
Single-Expression Functions Don’t Have Curly Braces 245
Single-Expression Functions Don’t Use the return Keyword 246
Single-Expression Functions Can Infer a Return Type 246
Type Widening Results in the Widest Type Being Returned 248
Functions Can Take Variable Numbers of Arguments 249
A vararg Argument Can Be Treated Like an Array 251
Functions in Kotlin have Scope 251
Local Functions Are Functions Inside Functions 252
Member Functions Are Defined in a Class 252
Extension Functions Extend Existing Behavior without Inheritance 253
Extend an Existing Closed Class Using Dot Notation 253
this Gives You Access to the Extension Class 255
Function Literals: Lambdas and Anonymous
Functions 257
Anonymous Functions Don’t Have Names 257
You Can Assign a Function to a Variable 258
Executable Code Makes for an “Executable” Variable 259
Higher-Order Functions Accept Functions as Arguments 260

xxii
Contents

The Result of a Function Is Not a Function 260


Function Notation Focuses on Input and Output 261
You Can Define a Function Inline 263
Lambda Expressions Are Functions with Less Syntax 264
You Can Omit Parameters Altogether 266
Lambda Expressions Use it for Single Parameters 266
It Makes Lambdas Work More Smoothly 267
Lambda Expressions Return the Last Execution Result 267
Trailing Functions as Arguments to Other Functions 268
Lots of Functions, Lots of Room for Problems 268

CHAPTER 11: SPEAKING IDIOMATIC KOTLIN 271

Scope Functions Provide Context to Code 271


Use Let to Provide Immediate Access to an Instance 272
let Gives You it to Access an Instance 273
The Scoped Code Blocks Are Actually Lambdas 274
let and Other Scope functions Are Largely about Convenience 275
You Can Chain Scoped Function Calls 275
An Outer it “Hides” an Inner it 276
Chaining Scope Functions and Nesting Scope Functions
Are Not the Same 277
Nesting Scope Functions Requires Care in Naming 277
Chaining Scope Functions Is Simpler and Cleaner 278
Prefer Chaining over Nesting 279
Many Chained Functions Start with a Nested Function 280
You Can Scope Functions to Non-Null Results 280
Accepting null Values Isn’t a Great Idea 282
Scope Functions Give You Null Options 282
Scope Functions Work on Other Functions . . . In Very Particular Ways 284
With Is a Scope Function for Processing an Instance 287
with Uses this as Its Object Reference 287
A this Reference Is Always Available 288
with Returns the Result of the Lambda 289
Run Is a Code Runner and Scope Function 289
Choosing a Scope Function Is a Matter of Style and Preference 290
run Doesn’t Have to Operate on an Object Instance 291
Apply Has a Context Object but No Return Value 292
apply Operates Upon an Instance 292
apply Returns the Context Object, Not the Lambda Result 293
?: Is Kotlin’s Elvis Operator 293
Also Gives You an Instance . . . but Operates on the Instance First 294

xxiii
Contents

also Is Just Another Scope Function 295


also Executes before Assignment 296
Scope Functions Summary 298

CHAPTER 12: INHERITANCE, ONE MORE TIME, WITH FEELING 303

Abstract Classes Require a Later Implementation 303


Abstract Classes Cannot Be Instantiated 304
Abstract Classes Define a Contract with Subclasses 306
Abstract Classes Can Define Concrete Properties and Functions 308
Subclasses Fulfill the Contract Written by an Abstract Class 310
Subclasses Should Vary Behavior 310
The Contract Allows for Uniform Treatment of Subclasses 311
Interfaces Define Behavior but Have No Body 313
Interfaces and Abstract Classes Are Similar 315
Interfaces Cannot Maintain State 316
A Class’s State Is the Values of Its Properties 317
An Interface Can Have Fixed Values 317
Interfaces Can Define Function Bodies 318
Interfaces Allow Multiple Forms of Implementation 319
A Class Can Implement Multiple Interfaces 320
Interface Property Names Can Get Confusing 321
Interfaces Can Decorate a Class 321
Delegation Offers Another Option for Extending Behavior 322
Abstract Classes Move from Generic to Specific 322
More Specificity Means More Inheritance 324
Delegating to a Property 326
Delegation Occurs at Instantiation 329
Inheritance Requires Forethought and Afterthought 330

CHAPTER 13: KOTLIN: THE NEXT STEP 331

Programming Kotlin for Android 331


Kotlin for Android Is Still Just Kotlin 331
Move from Concept to Example 333
Kotlin and Java Are Great Companions 333
Your IDE Is a Key Component 333
Kotlin Is Compiled to Bytecode for the Java Virtual Machine 335
Gradle Gives You Project Build Capabilities 335
When Kotlin Questions Still Exist 335
Use the Internet to Supplement Your Own Needs and Learning Style 336
Now What? 337

INDEX 339
xxiv
INTRODUCTION

For decades, the Java programming language has been the dominant force in compiled languages. While
there have been plenty of alternatives, it’s Java that has remained core to so many applications, from
desktop to server-side to mobile. This has become especially true for Android mobile development.
Finally, though, there is a real contender to at least live comfortably beside Java: Kotlin, a modern
programming language shepherded by JetBrains (www.jetbrains.com). It is not Java, but is com-
pletely interoperable with it. Kotlin feels a lot like Java, and will be easy to learn for developers
already familiar with the Java language, but offers several nice improvements.
Further, Kotlin is a full-blown programming language. It’s not just for mobile applications, or a visual
language that focuses on one specific application. Kotlin supports:
➤➤ Inheritance, interfaces, implementations, and class hierarchies
➤➤ Control and flow structures, both simple and complex
➤➤ Lambdas and scope functions
➤➤ Rich support for generics while still preserving strong typing
➤➤ Idiomatic approaches to development, giving Kotlin a “feel” all its own
You’ll also learn that while Kotlin is a new language, it doesn’t feel particularly new. That’s largely
because it builds upon Java, and doesn’t try to reinvent wheels. Rather, Kotlin reflects lessons that
thousands of programmers coding in Java (and other languages) employ on a daily basis. Kotlin takes
many of those lessons and makes them part of the language, enforcing strong typing and a strict com-
piler that may take some getting used to, but often produces cleaner and safer code.
There’s also an emphasis in Kotlin, and therefore in this book, on understanding inheritance. Whether
you’re using packages from third parties, working with the standard Kotlin libraries, or building your
own programs, you need a solid understanding of how classes interrelate, how subclassing works, and
how to use abstract classes along with interfaces to define behavior and ensure that behavior is imple-
mented. By the time you’re through with this book, you’ll be extremely comfortable with classes,
objects, and building inheritance trees.
The Kotlin website (kotlinlang.org) describes Kotlin as “a modern programming language that
makes developers happier.” With Kotlin and this book, you’ll be happier and more productive in your
Kotlin programming.

WHAT DOES THIS BOOK COVER?


This book takes a holistic approach to teaching you the Kotlin programming language, from a begin-
ner to a confident, complete Kotlin developer. By the time you’re finished, you’ll be able to write
Kotlin applications in a variety of contexts, from desktop to server-side to mobile.
Introduction

WILL THIS BOOK TEACH ME TO PROGRAM MOBILE APPLICATIONS


IN KOTLIN?

Yes, but you’ll need more than just this book to build rich mobile applications in
Kotlin. Kotlin is a rich language, and while there are books on all the packages
needed to build mobile languages, this is fundamentally a book on learning Kotlin
from the ground up. You’ll get a handle on how Kotlin deals with generics, inherit-
ance, and lambdas, all critical to mobile programming.
You can then take these concepts and extend them into mobile programming. You
can easily add the specifics of Android-related packages to your Kotlin base knowl-
edge, and use those mobile packages far more effectively than if you didn’t have the
fundamentals down.
If you are anxious to begin your mobile programming journey sooner, consider
picking up a book focused on Kotlin mobile programming, and hop back and forth.
Read and work through Chapter 1 of this book, and then do the same for the book
focused on mobile programming. You’ll have to context switch a bit more, but you’ll
be learning fundamentals alongside specific mobile techniques.

This book covers the following topics:


Chapter 1: Objects All the Way Down This chapter takes you from getting Kotlin installed
to writing your first Kotlin program. You’ll learn about functions from the start, and how to
interact with the command line through a not-quite “Hello, World!” application. You’ll also
immediately begin to see the role of objects and classes in Kotlin, and refine your understand-
ing of what a class is, what an object is, and what an object instance is.
Chapter 2: It’s Hard to Break Kotlin This chapter delves into one of the distinguishing fea-
tures of Kotlin: its rigid stance on type safety. You’ll learn about Kotlin’s types and begin to
grasp choosing the right type for the right task. You’ll also get familiar with val and var and
how Kotlin allows for change.
Chapter 3: Kotlin Is Extremely Classy Like any object-oriented language, much of your
work with Kotlin will be writing classes. This chapter digs into classes in Kotlin and looks
at the basic building blocks of all Kotlin objects. You’ll also override some functions and get
deep into some of the most fundamental of Kotlin functions: equals() and hashCode().
Chapter 4: Inheritance Matters This chapter begins a multichapter journey into Kotlin
inheritance. You’ll learn about Kotlin’s constructors and the relatively unique concept of sec-
ondary constructors. You’ll also learn more about the Any class, understand that inheritance
is truly essential for all Kotlin programming, and learn why writing good superclasses is one
of the most important skills you can develop in all your programming learning.

xxvi
Introduction

Chapter 5: Lists and Sets and Maps, Oh My! This chapter moves away (briefly) from
classes and inheritance to add Kotlin collections to your arsenal. You’ll use these collection
classes over and over in your programming, so understanding how a Set is different from a
Map, and how both are different from a List, is essential. You’ll also dig further into Kotlin
mutability and immutability—when data can and cannot change—as well as a variety of
ways to iterate over collections of all types.
Chapter 6: The Future (in Kotlin) Is Generic Generics are a difficult and nuanced topic in
most programming languages. They require a deep understanding of how languages are built.
This chapter gets into those depths, and provides you more flexibility in building classes that
can be used in a variety of contexts than possible without generics. You’ll also learn about
covariance, contravariance, and invariance. These might not be the hot topics at the water
cooler, but they’ll be key to building programs that use generics correctly, and also level up
your understanding of inheritance and subclassing.
Chapter 7: Flying through Control Structures Control structures are the bread and butter of
most programming languages. This chapter breaks down your options, covering if and else,
when, for, while, and do. Along the way, you’ll focus on controlling the flow of an applica-
tion or set of applications all while getting a handle on the semantics and mechanics of these
structures.
Chapter 8: Data Classes This chapter introduces data classes, another very cool Kotlin
concept. While not specific to only Kotlin, you’ll find that data classes offer you a quick and
flexible option for representing data more efficiently than older languages. You’ll also really
push data classes, going beyond a simple data object and getting into constructors, overriding
properties, and both subclassing with and extending from data classes.
Chapter 9: Enums and Sealed, More Specialty Classes This chapter introduces enums, a far
superior approach to String constants. You’ll learn why using Strings for constant values is
a really bad idea, and how enums give you greater flexibility and type safety, as well as mak-
ing your code easier to write. From enums, you’ll move into sealed classes, a particularly cool
feature of Kotlin that lets you turbo-charge the concept of enums even further. You’ll also dig
into companion objects and factories, all of which contribute to a robust type-safe approach
to programming where previously only String types were used.
Chapter 10: Functions and Functions and Functions It may seem odd to have a chapter this
late in the book that purports to focus on functions. However, as with most fundamentals in
any discipline, you’ll have to revisit the basics over and over again, shoring up weaknesses
and adding nuance. This chapter does just that with functions. You’ll dig more deeply into
just how arguments really work, and how many options Kotlin provides to you in working
with data going into and out of your functions.
Chapter 11: Speaking Idiomatic Kotlin Kotlin, like all programming languages, has certain
patterns of usage that seasoned programmers revert to time and time again. This chapter
discusses these and some of the idioms of Kotlin. You’ll get a jump start on writing Kotlin
that looks like Kotlin is “supposed to” all while understanding how you have a tremendous
amount of flexibility in choosing how to make your Kotlin programs feel like “you.”

xxvii
Discovering Diverse Content Through
Random Scribd Documents
The Speaker being conducted to the Chair, by Mr. Van Cortlandt
and Mr. Alston, addressed the House as follows:

Gentlemen of the House of Representatives:


You will please to accept my most grateful acknowledgments for
the honor which by your suffrages on this occasion you have
conferred upon me. I am sensible of my own inability to perform the
important duties you have been pleased to assign me, in the most
desirable manner; but relying on your candor and readiness to afford
me your aid, I accept the trust. And be assured, gentlemen, that it
will be my assiduous endeavor to discharge the duties of the office
faithfully and impartially; and in a manner which, in my opinion,
shall be best calculated to meet your wishes and afford me the
consolation of an approving conscience.

The oath to support the Constitution of the United States, as


prescribed by the act, entitled “An act to regulate the time and
manner of administering certain oaths,” was administered by Mr. Van
Cortlandt, one of the Representatives for the State of New York, to
the Speaker; and then the same oath, or affirmation, was
administered by Mr. Speaker to all the members present.
George Poindexter, Esq., having also appeared as the delegate from
the Mississippi Territory of the United States, the said oath was
administered to him by the Speaker. The same oath, together with
the oath of office prescribed by the said recited act, were also
administered by Mr. Speaker to the Clerk.
A message from the Senate informed the House that a quorum of
the Senate is assembled, and ready to proceed to business. Also,
that the Senate have appointed a committee on their part, jointly
with such committee as may be appointed on the part of this House,
to wait on the President of the United States, and inform him that a
quorum of the two Houses is assembled, and ready to receive any
communications he may be pleased to make to them.
Ordered, That a message be sent to the Senate, to inform them
that a quorum of this House is assembled, and have elected Joseph
B. Varnum, Esq., one of the Representatives for the State of
Massachusetts, their Speaker; and that the Clerk of this House do go
with the said message.
Mr. Bassett, Mr. Goldsborough, and Mr. Masters, were appointed a
committee on the part of this House, jointly with the committee
appointed on the part of the Senate, to wait on the President of the
United States, and inform him that a quorum of the two Houses is
assembled, and ready to receive any communication that he may be
pleased to make to them.

Election of Clerk, &c.

The House next proceeded to the election of a Clerk. The same


tellers which had been appointed on the former election having been
named by the Speaker on this, the members proceeded to ballot,
and Patrick Magruder having received 72 votes was declared duly
elected.

Tuesday, October 27.


Several other members, to wit: from Virginia, Abram Trigg and
Alexander Wilson; from South Carolina, Robert Marion; and from
Tennessee, George W. Campbell, appeared, produced their credentials,
were qualified, and took their seats in the House.

Wednesday, October 28.


Another member, to wit, William Hoge, from Pennsylvania,
appeared, produced his credentials, was qualified, and took his seat
in the House.

Thursday, October 29.


Another member, to wit, William Blackledge, from North Carolina,
appeared, produced his credentials, was qualified, and took his seat
in the House.

Friday, October 30.


The House proceeded, by ballot, to the appointment of a Chaplain
to Congress, on the part of this House; and, upon examining the
ballots, a majority of the votes of the whole House was found in
favor of the Rev. Obadiah B. Brown.

Monday, November 2.
Several other members, to wit: from Massachusetts, Ezekiel Bacon;
from New York, Gurdon S. Mumford; from North Carolina, James
Holland; from Kentucky, Matthew Lyon; and from South Carolina,
Richard Wynn, appeared, produced their credentials, were qualified,
and took their seats in the House.

Thursday, November 5.

Revolutionary Pensions.

Mr. Dana said it was well known, that during the last Congress, an
act was passed for the relief of persons claiming pensions. The
object of the act was, to grant relief to some whose cases were not
embraced by the former act, and to grant an increased allowance to
others who had not, as yet, received sufficient. This act provides for
taking depositions before the district judge, in cases where the
claimants have never been placed on the pension list, as well as for
examination of the claims of those who apply to have their pensions
increased. Whether any compensation should be allowed for issuing
commissions, or for making the examinations required, is not
declared by the act. A difference of practice, he understood, had
taken place. In some cases, commissions were issued gratuitously by
the district judge; in other cases, these poor solicitors were obliged,
from their small pittance, to pay for these services. If any
compensation were to be allowed for this service, he thought it
should be paid from the public treasury. Whatever might be the
mode adopted, he wished it to be fixed by law. For this purpose he
offered the following resolution:

“Resolved, That a committee be appointed to inquire what


compensation shall be allowed for issuing commissions giving
authority for taking testimony, or examining evidence relative to
claims or applications under the act to provide for persons who have
been disabled by known wounds received in the Revolutionary war,
and that the committee have leave to report by bill or otherwise.”

Frigate Chesapeake.

Mr. Quincy said the House would recollect that when in Committee
of the Whole on the state of the Union, some days ago, he
submitted an amendment to a resolution of the gentleman from
Virginia, (Mr. Dawson,) which went to an inquiry into the
circumstances of the attack on the Chesapeake, and the causes
assigned for it, as well as the manner in which it was repelled. At
that time two objections of some apparent validity were urged
against this motion; the one was that it might have an improper
effect upon a pending trial, the other was as to its form. To obviate
these objections, he had modified the resolution, which he should
now offer to the House.
Mr. Q. read his motion, as follows:

“Resolved, That the committee to whom was referred so much of


the Message of the President of the United States as relates to
aggressions committed within our ports and waters, by foreign
armed vessels, to violations of our jurisdiction, and to measures
necessary for the protection of our ports and harbors, be instructed
to inquire into the circumstances of the attack made on the frigate
Chesapeake in June last, and the pretexts or causes assigned for
making it, and to report the same in detail to the House.”

Mr. Q. would lay before the House his reasons for offering this
resolution. He could not acquiesce in the course which had been
given to that part of the President’s Message which relates to the
attack on the Chesapeake. He could not reconcile it with the sense
of justice or with the honor of this House. He asked gentlemen to
consider our situation in relation to this subject. A violent attack is
made upon one of our public ships of war, in a manner undeniably
hostile. A great degree of excitement has taken place in the public
mind throughout the continent. Our newspapers have teemed with
every species of information, a part of which has been correct, and a
part incorrect; which has sometimes fallen short of the truth, and
sometimes exceeded it; has been sometimes official, and sometimes
unofficial. In this situation of things, the President of the United
States deemed it wise and prudent to call an extraordinary session
of this Legislature. We are now assembled. He has made a
communication to us, and this attack is a striking feature in it. This is
our situation. What have we done? The House has gone into a
Committee of the Whole, taken up the Message of the President, cut
it up into parts, according to Parliamentary custom; and we have
taken as many of those parts as we pleased and referred them to
particular committees; some of which are a kind of patchwork
committees. In all of these references, notwithstanding it was the
very object which occasioned the early meeting of the present
session, no mention is made of the attack on the Chesapeake. The
committee, which he proposed to instruct on this subject, had what
related to aggressions committed within our ports and waters
submitted to them generally, but they have no compass by which to
steer; no prominent object is placed before them. He could not
reconcile this manner of acting with his duty. He deemed it
necessary to obtain a full development of all the circumstances
relative to this affair, in order that Congress, and the people at large,
may form a correct judgment of our situation. The course adopted is
not the course to gain the information so desirable. It is a course of
Parliamentary ignorance, not a course of development. It is a course
of concealment. He spoke as to the general effect of measures, and
not as to gentlemen’s motives.
He inquired of gentlemen what method they would pursue, if they
wanted to understand any particular subject? Would they not refer it
to a distinct committee, and not mix it up with extraneous matter?
And if you give a committee two or three distinct objects to act
upon, but wish them to attend more especially to one, it is proper to
give them specific instructions to that point. This is the way to come
at the proper understanding of a subject. But, on the contrary, if it
were the wish of any member of this House to promote
concealment, to prevent a knowledge of facts, the way is obvious. It
would be to place three or four subjects together, and to suffer the
committee to which they are referred to act as they please upon
them. We know that committees thus left to themselves, will never
do too much.
It was because the people of the United States wish to know
something on this subject, that he made this motion. It may be said
that this committee have already the power, and that they may
make the necessary inquiries without this instruction. But it is the
duty of this House to be certain that they will do so. Indeed, if the
committee were now proceeding in this inquiry, this would be no
good reason why this motion ought not to be adopted. If, without
being instructed by this House, the committee should report the
facts now called for, the honor of the act would rest upon that
committee; whereas it ought to rest upon this House.
Perhaps it may be said, as on a former occasion, that every man,
woman, and child, in the United States is acquainted with these
facts; but what is known from popular report, or newspaper
information, is not the kind of knowledge we want. We want facts
from the proper authority.
An objection had been made to this course, that it would be
casting a censure upon the committee. Not so; it would be no more
than drawing the attention of an organ of the House to a particular
subject. It may be objected to, because a negotiation is pending;
but what is done by Congress, at this time, can have no effect on a
negotiation carrying on across the Atlantic. The House is at present
calm and tranquil, and this is therefore a proper time to undertake
an investigation of the facts required. Let the negotiation terminate
as it may, we shall never have a fair inquiry into these facts, unless
we enter upon it at present. Suppose, said he, the negotiation has a
favorable issue, and no inquiry has been made, is there a member
present who will say the inquiry would then be entered upon? No, it
would be said to be an old wound, which ought not to be probed,
but forgotten. But suppose, on the other hand, that the negotiation
should be abruptly broken off, and this House should be called upon
to put the nation in hostile array, would that be a proper time for
entering upon the proposed inquiry? Would the House be in a fit
state for deliberating upon the facts required? Indeed, the subject
appeared to him so clear, and the duty to bring forward this motion
so impressive, that he could not refrain from making it.
Mr. Burwell said he had hoped he should have been able to have
satisfied the gentleman from Massachusetts, as to the attention of
the committee to whom this duty was assigned; but after an
expression which had dropped from him, he despaired of doing it.
He would, however, inform the House that the committee to whom
the subject was referred were engaged in a course of investigation
on the very part of it now agitated, and had come to a
determination to obtain, from the proper authority, a correct detail of
the circumstances attending this particular attack; not content with
this, they were about to call on the Government for a detail of all
aggressions that had been committed within our ports and waters.
Mr. Blount said, that, at the moment the gentleman from
Massachusetts had moved this resolution, he was in the committee-
room, in the act of addressing a note to the Secretary of State on
this subject, according to the direction of the committee, calling for a
full and correct statement of all the facts relative to the aggression
committed on the frigate Chesapeake. For the satisfaction of the
gentleman, he would read the note which he had written. [Mr. B.
then opened and read the note.]

Thursday, November 12.


Two other members, to wit: from Massachusetts, Jacob
Crowninshield; and from Pennsylvania, Joseph Clay, appeared,
produced their credentials, were qualified, and took their seats in the
House.
The Speaker laid before the House sundry documents, transmitted
to him by Duncan McFarland, of the State of North Carolina, relative
to his claim to a seat in this House, as a Representative for said
State, in the room of John Culpepper; which were referred to the
Committee of Elections.

Maryland Contested Election.[55]

The House then resolved itself into a Committee of the Whole on


the report of the Committee of Elections, to whom was referred the
memorial of Joshua Barney, of the State of Maryland. The report of
the Committee of Elections is as follows:

The Committee of Elections, to whom was committed the petition


of Joshua Barney, of the city of Baltimore, praying to be admitted to
a seat in the House, he having, in his opinion, the highest number of
votes given to a candidate legally qualified to represent the city of
Baltimore, having carefully examined the facts stated on both sides,
and compared the laws of Maryland under which the said election
was held, with the Constitution of the United States, report—
That, by an act of the Assembly of Maryland, passed in November,
1790, it is required that the member shall be an inhabitant of his
district at the time of his election, and shall have resided therein
twelve calendar months immediately before.
By another act of the Assembly of Maryland, passed in November,
1802, it is enacted that Baltimore town and county shall be the fifth
district, which district shall be entitled to send two Representatives
to Congress, one of which shall be a resident of Baltimore county,
and the other a resident of Baltimore city.
That Joshua Barney is a citizen of Maryland, and has been a
resident of Baltimore city for many years.
That William McCreery has been for many years a citizen of
Maryland, and a resident of the city of Baltimore; but that, in the
year 1803, he removed himself and his family to his estate in
Baltimore county; that, from that time, though he himself has
occasionally resided in Baltimore, yet he, with his wife and family,
have not made the city their settled residence.
That William McCreery states that his intention was, and still is, to
reside with his family on his country estate in summer, and in the
city of Baltimore in winter; but that, ever since he has removed his
family to his farm, he has been obliged every winter, in the public
service, to reside, and frequently with his family, in the city of
Washington, which prevented him from removing his family,
agreeably to his intention, to the city of Baltimore; but he resided
himself in the city of Baltimore five or six days before the election;
that he and his family were residing in the same situation, when he
was elected to serve in the ninth Congress, that they were when he
was elected into the present Congress; that, however, not wishing to
have been taken up as a candidate at the last election, he expressed
to some of his friends some apprehensions that exceptions might be
made on account of his constant family residence not being in the
city of Baltimore.
At the election in that district for the Congress now in session,
Nicholas R. Moore had 6,164 votes; he is a resident in Baltimore
county; and William McCreery, against whose right to a seat in this
House objection is made on account of residence, had 3,559 votes;
and Joshua Barney, who claims a seat in this House, and it is
admitted is a resident of Baltimore city, had 2,063 votes; and John
Seat, also a resident in Baltimore city, had 353 votes. The above
statement of facts being admitted by the parties, further evidence
was not required. No question was taken on the legal residence of
William McCreery in the city of Baltimore.
The committee proceeded to examine the constitution, with
relation to the case submitted to them, and find that qualifications of
members are therein determined, without reserving any authority to
the State Legislatures to change, add to, or diminish those
qualifications; and that, by that instrument, Congress is constituted
the sole judge of the qualifications prescribed by it, and are obliged
to decide agreeably to the constitutional rules; but the State
Legislatures being, by the constitution, authorized to prescribe the
time, place and manner of holding the elections, in controversies
arising under this authority, Congress are obliged to decide
agreeably to the laws of the respective States.
On the most mature consideration of the case submitted to them,
the committee are of opinion that William McCreery is duly qualified
to represent the fifth district of the State of Maryland, and that the
law of that State, restricting the residence of the members of
Congress to any particular part of the district for which they may be
chosen, is contrary to the Constitution of the United States:
therefore,
“Resolved, That William McCreery is entitled to his seat in this
House.”

Tuesday, November 17.


Another member, to wit, Marmaduke Williams, from North Carolina,
appeared, produced his credentials, was qualified, and took his seat
in the House.
Frigate Chesapeake.

Mr. Blount, from the committee to whom was referred so much of


the Message of the President as relates to aggressions, &c., made a
report.
The report commences with an expression of sensibility at the
outrage committed on the Chesapeake; states the receipt of
information relative thereto from the State and Navy Departments;
presents a general view of the circumstances; observes that it might
be said to have been incontestably proved that William Ware, John
Strachan, and Daniel Martin are citizens of the United States. But the
committee add, that they conceive it unnecessary for them or the
House to go into any inquiry on that part of the subject, as in their
opinion whether the men taken from the Chesapeake were or were
not citizens of the United States, and whether the Chesapeake was
or was not within the acknowledged limits of the United States at
the time they were taken, the character of the act of taking them
remains the same.

“From the foregoing facts, it appears to your committee that the


outrage committed on the frigate Chesapeake has been stamped
with circumstances of indignity and insult of which there is scarcely
to be found a parallel in the history of civilized nations, and requires
only the sanction of the Government under color of whose authority
it was perpetrated to make it just cause of, if not an irresistible call
for, instant and severe retaliation. Whether it will receive that
sanction, or be disavowed, and declared an unauthorized act of a
subordinate officer, remains to be determined by the answer which
shall be given to the demand of explanation. That answer (now daily
expected) will either sink the detestable act into piracy, or expand it
to the magnitude of premeditated hostility against the sovereignty
and independence of this nation; and until its true character shall be
fixed and known, your committee deem it expedient to decline
expressing any opinion as to the measures proper to be adopted in
relation to it. But, as other acts of aggression have been committed
within our ports and waters by British ships of war, as well anterior
as posterior to this, some of them manifesting the same disregard of
our national rights, and seeming to flow from the same contempt for
the authority of our laws; and especially as the British squadron, of
which the Leopard was one, after being notified of the President’s
proclamation, ordering them to depart from the waters of the United
States which they knew had been published in conformity to an act
of Congress, anchored within the capes of Chesapeake Bay, and in
that situation remained, capturing American vessels, even within our
acknowledged territorial limits, and sending them to Halifax for
adjudication—impressing seamen on board American vessels—firing
on vessels and boats of all descriptions, having occasion to pass
near them in pursuit of their lawful trade, and occasionally
denouncing threats, calculated to alarm and irritate the good people
of the United States, particularly the inhabitants of Norfolk and
Hampton—all which facts are substantiated by the accompanying
documents, Nos. 1 to 6—the committee are of opinion that it is
expedient to provide more effectually for the protection of our ports
and harbors; but not being prepared to report specifically on that
subject, they ask further indulgence of the House, and beg leave to
submit for their consideration the following resolution:
“Resolved, That the attack of the British ship of war Leopard on
the United States frigate Chesapeake was a flagrant violation of the
jurisdiction of the United States, and that the continuance of the
British squadron (of which the Leopard was one) in their waters,
after being notified of the proclamation of the President of the
United States, ordering them to depart the same, was a further
violation thereof.”

The report was referred to a Committee of the Whole on Monday.


On a motion of Mr. Bassett, that the proceedings of this day, with
closed doors, ought to be kept secret, the question being taken
thereupon, it passed in the negative—yeas 22, nays 104.
Wednesday, November 18

British Aggressions.

Mr. Quincy said the House might have observed, that in the
Message of the President of the United States to Congress, delivered
on the 27th of October, there was an express reference to a certain
Proclamation interdicting our ports and harbors to British armed
vessels. It was in Great Britain, he understood, a universal
Parliamentary rule, that proclamations of this kind should be laid
before Parliament; and in this country it had heretofore been the
usual practice. In the case of the Proclamation of Neutrality, issued
by President Washington, in 1793, in his first communication to
Congress, he laid it before them, and it was entered on the Journals.
Circumstances of however great notoriety were not official
information on which they could act; but, were it so, he had not
been able to find it in any papers he could procure. He had expected
it would have been connected with the report of the committee on
aggressions; but, as it was not yet before the House, he moved the
following resolution:

Resolved, That the President of the United States be requested to


cause to be laid before this House a copy of his Proclamation
interdicting our harbors and waters to British armed vessels, &c.,
referred to in his Message of the 27th of October last.

Mr. Crowninshield could not see any necessity for calling for this
paper. He well recollected that the President had issued
proclamations on other subjects which had never been laid before
the House. That issued in the case of an aggression committed by
Captain Whitby, commanding an armed ship of Great Britain, had
not been transmitted to the House; so, in the case of the famous
conspiracy of Mr. Burr, a proclamation was issued at the time, and
not laid before the House, nor had the House thought necessary to
call for these papers. They were before the public, and every
member of the House must have perused them. Mr. C. wished his
colleague to show some necessity for the present call; for he could
see none. The practice which had taken place in other countries was
not to govern them; he might as well have drawn a precedent from
the practice of France, Germany, or any other country, as from Great
Britain. Besides, he doubted whether it was the practice there. It
was well known that, under that Government, the King and Council
legislated in a variety of instances. The citizens of this country had
suffered severely by these measures. They legislated for neutrals in
this way, and property to an immense amount had been taken from
our merchants under these orders, and Mr. C. did not know that
their acts in such cases had been laid before the Parliament, or even
called for. He should, however, have no objection to the call in this
instance, but that he saw no necessity for it. The gentleman might
perhaps not have seen the Proclamation; but it was well known that
it had been published in almost all the papers in the Union. It first
appeared in a paper of this city, and he presumed was copied from
that paper into the others. He had no doubt but the Proclamation
would be communicated, or any other paper that might be called for.
Mr. Alston said it was certainly very immaterial whether the
resolution was adopted or not; but it was certainly causing
considerable trouble for nothing, to submit such a resolution to the
House. The gentleman might have laid his hands on it in any paper
published in the Union. Did that gentleman receive an official copy of
the proclamation for convening Congress at this time? If he did, Mr.
A. said he had an advantage over him; for he saw the Proclamation
in the newspapers, and came on in consequence; and if there had
been any proclamation issued, Mr. Q. could have found it in the
newspapers. He had an objection to this resolution, because it was
going out of the way; he had never before known an instance of a
call upon the President for any proclamation which he had not
thought proper to lay before them.
Mr. Quincy said he had cited the example of Great Britain, because
that was the country from whose Parliamentary practice so many
precedents had been drawn. The Proclamation of President
Washington, however, was published in all the papers on the
continent, and yet the President had laid it before Congress on the
first day of the succeeding session. He would refer to the mode in
which it was presented, in order to convince the House it had been
heretofore done. The case was thus: The President of the United
States, after some prefatory observations, tells them that the
Proclamation laid before the House had been issued. Immediately
after this, the Journal says, a Message was received from the
President of the United States, enclosing a copy of the Proclamation.
The case in the present instance was of much more importance: he
had no conception, before he saw the report of the committee, but
that it would be laid before them; he had not conceived it possible
that it would not be laid before them in some way. It had been said,
that he should give reasons for calling for it. He thought that in an
important case like this the House should know what was done. He
had no objection to the Proclamation; but it contained certain
national principles to which they ought to refer.
He was at a loss to account for the opposition which this motion
received from some quarters of the House; it was impossible it could
be made on any other grounds than a determination to vote down at
all events any question that might be moved, or any inquiry that
might be requested on the part of gentlemen of one description in
the House. It seemed to him to be following up the advice which
had lately been given to them through the channel of a paper
printed in this city, which was understood generally to speak a demi-
official language. I have before me, (said he,) the words in which
this House were a short time since addressed in that paper, by a
person making observations on a motion which Mr. Q. had made,
and which was negatived. Mr. Q. then read the following paragraph
from the National Intelligencer, of November 9:

“Let them weigh well the advice of an enemy before they adopt it.
Let them act as they have done in the present instance. Let them
entertain no apprehensions on the sense of popularity, even though
their adversaries should sound the tocsin of alarm, and declare
themselves in patriotic strains the exclusive friends of the people. Let
them remember that while their opponents have nothing to do but
talk, they have to act.”

And was this the language in which this House was to be


addressed through the medium of a newspaper printed at their
doors? Was a mere printer to obtrude upon them his advice as to
what course they were to pursue in relation to the interest of the
nation, and to denounce a portion of the House as unworthy of
notice or confidence? He hoped not. But he could account for the
opposition which was now given to this motion from no other
reasons; for if a Proclamation of this kind had been issued, they
ought to have it before them.
Mr. Q. said he possessed no interests different from any other
member of this House; and assuming the right to which he was
entitled, he would ask for information when he had occasion for it.
Mr. Crowninshield felt much surprised at what had been said by the
gentleman last up. Had Mr. C. said any thing about it, had he made
any allusion to what had appeared in a newspaper in this city? The
publication was made before he had been able to arrive at this city.
[Mr. Quincy here remarked, he did not refer to him.] Mr. C. did not
know to whom he could refer, except to him or his friend from North
Carolina. He had no intention to make any remark to hurt the
gentleman’s feelings with respect to what had appeared in a
newspaper of this city; but what relation could that have to the
subject under consideration? If the paper alluded to had infringed
any privilege appertaining to him as a member of that House, of
which Mr. C. said he knew nothing, he had his remedy. If of a
personal nature, the gentleman had other means of satisfaction. He
was perfectly at a loss as to the object the gentleman could have in
bringing the matter up now. Mr. C. had alluded to the same paper: it
was the only paper of any consequence in the city, and the President
was obliged to take that course to circulate official acts throughout
the Union. It had always been the custom of the President to publish
his Proclamations, but in no instance had he laid them before the
House. The two extraordinary sessions of Congress had been held
by Proclamation published in the newspapers, and the Proclamations
for convening them had not been laid before the House. It having
been done by another President had no bearing on the present case:
no law existed authorizing President Washington to issue such a
Proclamation as that referred to; but the Proclamation now referred
to, as well that in the case of Mr. Burr, were issued under an act of
Congress. Mr. C. had no particular objection to the call; but he could
not see the necessity for it. With respect to precedents in other
countries, he wished them to have no influence on the proceedings
in this.
Mr. Burwell did not rise to oppose the resolution; he was willing
that the Proclamation should be sent to them by the President; but
the gentleman had expressed his surprise that he did not find that
Proclamation contained in the report of the committee. The only
reason was, that they had supposed it was sufficiently official in the
newspapers, and had referred to them when occasion required, as
they would have done to any other authority. He held it a correct
proceeding, that it was the right of any member of that House to call
for any information relative to any subject; he should always favor
such an application; he therefore did not rise to oppose the
gentleman’s motion, but to apologize for the committee’s not having
reported it.
Mr. Dana said that the observations of the gentleman from Virginia
had been made with his general candor he had no doubt, but the
committee considered such reference as they had made correct; but
as no public prints were strictly official, and as they were called upon
to deliberate on the Proclamation itself, he thought it necessary they
should have it before them. Were they not called together on this
subject particularly, he might not see the same necessity for having
it; but as it was to be the basis in some measure of their
proceedings, they ought to have an official copy of it. Mr. D. also
thought it was more correct, whenever Congress were called
together by Proclamation, that they should be specially notified. The
gentleman from Massachusetts was in an error so far as related to
the form of giving notice of extraordinary sittings; he had
understood the gentleman to say, that Congress were called
together by a Proclamation published in a newspaper, which was
official notice. This was not the correct course. It was true they were
now all gathered together; but their journals would not show how.
When an extraordinary session had been called formerly, a letter had
been addressed to each member from the Secretary of State,
enclosing the Proclamation for the purpose; and this was capable of
being done in every instance, by transmitting these letters to the
Executive of each State, who might notify them individually. This had
been the course, and he thought it more correct than the other.
The question on the resolution being taken, was carried, 70 to 32;
and Messrs. Quincy and Burwell named a committee to wait on the
President for the purpose.

Thursday, November 19.


British Armed Vessels.

The following Message was received from the President of the


United States:
To the House of Representatives of the United States:
According to the request expressed in your resolution of the
eighteenth instant, I now transmit a copy of my proclamation
interdicting our harbors and waters to British armed vessels, and
forbidding intercourse with them, referred to in my message of the
twenty-seventh of October last.
TH. JEFFERSON.
November 19, 1807.

By the President of the United States of America:


A PROCLAMATION.
During the wars which, for some time, have unhappily prevailed
among the powers of Europe, the United States of America, firm in
their principles of peace, have endeavored, by justice, by a regular
discharge of all their national and social duties, and by every friendly
office their situation has admitted, to maintain with all the
belligerents their accustomed relations of friendship, hospitality, and
commercial intercourse. Taking no part in the questions which
animate these powers against each other, nor permitting themselves
to entertain a wish but for the restoration of general peace, they
have observed with good faith the neutrality they assumed; and they
believe that no instance of a departure from its duties can be justly
imputed to them by any nation. A free use of their harbors and
waters, the means of refitting and of refreshment, of succor to their
sick and suffering, have, at all times, and on equal principles, been
extended to all, and this, too, amidst a constant recurrence of acts
of insubordination to the laws, of violence to the persons, and of
trespasses on the property of our citizens, committed by officers of
one of the belligerent parties received among us. In truth, these
abuses of the laws of hospitality have, with few exceptions, become
habitual to the commanders of the British armed vessels hovering on
our coasts, and frequenting our harbors. They have been the subject
of repeated representations to their Government. Assurances have
been given that proper orders should restrain them within the limits
of the rights and of the respect due to a friendly nation; but these
orders and assurances have been without effect; no instance of
punishment for past wrongs has taken place. At length a deed,
transcending all we have hitherto seen or suffered, brings the public
sensibility to a serious crisis, and our forbearance to a necessary
pause. A frigate of the United States, trusting to a state of peace,
and leaving her harbor on a distant service, has been surprised and
attacked by a British vessel of a superior force, one of a squadron
then lying in our waters and covering the transaction, and has been
disabled from service, with the loss of a number of men killed and
wounded. This enormity was not only without provocation or
justifiable cause, but was committed with the avowed purpose of
taking by force, from a ship of war of the United States, a part of
her crew; and that no circumstance might be wanting to mark its
character, it had been previously ascertained that the seamen
demanded were native citizens of the United States. Having effected
her purpose she returned to anchor with her squadron within our
jurisdiction. Hospitality under such circumstances ceases to be a
duty; and a continuance of it, with such uncontrolled abuses, would
tend only, by multiplying injuries and irritations, to bring on a
rupture between the two nations. This extreme resort is equally
opposed to the interests of both, as it is to assurances of the most
friendly dispositions on the part of the British Government, in the
midst of which this outrage has been committed. In this light the
subject cannot but present itself to that Government, and strengthen
the motives to an honorable reparation of the wrong which has been
done, and to that effectual control of its naval commanders, which
alone can justify the Government of the United States in the exercise
of those hospitalities it is now constrained to discontinue.
In consideration of these circumstances and of the right of every
nation to regulate its own police, to provide for its peace and for the
safety of its citizens, and consequently to refuse the admission of
armed vessels into its harbors or waters, either in such numbers or
of such descriptions, as are inconsistent with these, or with the
maintenance of the authority of the laws, I have thought proper, in
pursuance of the authorities specially given by law, to issue this my
Proclamation, hereby requiring all armed vessels bearing
commissions under the Government of Great Britain, now within the
harbors or waters of the United States, immediately and without any
delay to depart from the same, and interdicting the entrance of all
the said harbors and waters to the said armed vessels, and to all
others bearing commissions under the authority of the British
Government.
And if the said vessels, or any of them, shall fail to depart as
aforesaid, or if they or any others, so interdicted, shall hereafter
enter the harbors or waters aforesaid, I do in that case forbid all
intercourse with them, or any of them, their officers or crews, and
do prohibit all supplies and aid from being furnished to them or any
of them.
And I do declare, and make known, that if any person from or
within the jurisdictional limits of the United States, shall afford any
aid to any such vessel, contrary to the prohibition contained in this
Proclamation, either in repairing any such vessel, or in furnishing
her, her officers or crew, with supplies of any kind, or in any manner
whatsoever, or if any pilot shall assist in navigating any of the said
armed vessels, unless it be for the purpose of carrying them, in the
first instance, beyond the limits and jurisdiction of the United States,
or unless it be in the case of a vessel forced by distress, or charged
with public despatches as hereinafter provided for, such person or
persons shall, on conviction, suffer all the pains and penalties by the
laws provided for such offences.
And I do hereby enjoin and require all persons bearing office, civil
or military, within or under the authority of the United States, and all
others, citizens or inhabitants thereof, or being within the same, with
vigilance and promptitude to exert their respective authorities, and
to be aiding and assisting to the carrying this Proclamation, and
every part thereof, into full effect.
Provided, nevertheless, that if any such vessel shall be forced into
the harbors or waters of the United States, by distress, by the
dangers of the sea, or by the pursuit of an enemy, or shall enter
them charged with despatches or business from their Government,
or shall be a public packet for the conveyance of letters and
despatches, the commanding officer immediately reporting his vessel
to the collector of the district, stating the object or cause of entering
the said harbors or waters, and conforming himself to the
regulations in that case prescribed under the authority of the laws,
shall be allowed the benefit of such regulations respecting repairs,
supplies, stay, intercourse, and departure, as shall be permitted
under the same authority.
In testimony whereof, I have caused the seal of the United States
to be affixed to these presents, and signed the same.
Given at the City of Washington the second day of July, in the year
of our Lord one thousand eight hundred and seven, and of the
sovereignty and independence of the United States the thirty-first.
TH. JEFFERSON.
By the President:
JAMES MADISON,
Secretary of State.

The Message was read, and, together with the Proclamation,


ordered to lie on the table.

Saturday, November 21.


Sir James Jay.

Mr. Jones moved that the House should, according to the order of
the day, go into Committee of the Whole on the report in favor of
the petition of Sir James Jay. Agreed to, 18 to 29. The report being
read with the letter from the Secretary of State accompanying it,
Mr. Taylor opposed and Mr. Jones supported it.
The question being taken on concurrence with the report, the
votes were, in favor of it 45, against it 46; there appearing some
doubt whether this decision was correct, a second count was about
to be had, when a debate took place, in which Messrs. Upham, Cook,
Dana, Quincy, loan, and Blackledge, supported, and Messrs. J. Clay,
Gardenier, D. R. Williams, Holland, Taylor, and Burwell opposed the
report.
In support of the report it was urged that the secret mode of
correspondence, for which the petitioner prays a compensation, was
very useful in the Revolutionary War, and no doubt might be again;
that the testimony in favor of the invention was very satisfactory;
that there was on file in the office of the Secretary of State, a letter
written by General Washington in this invisible ink; that Mr. Jay had
never received compensation; that although it had been used by
various persons, none had ever yet known the composition of it but
himself; that the report was only to authorize the President to
purchase this secret if he thought fit, leaving him the judge of its
utility.
Those who opposed the report, argued that it was absurd to vote
away money for a thing they did not and could not understand; that
there never yet was a secret ink made but a composition could be
invented that would bring it out, and that possibly Sir James himself
might know such a composition; that the House had no security
before them that it was not or would not be disclosed to other
Governments as well as this; that if secret correspondence was
wanted, it had from late occurrences appeared that Entick’s
Dictionary and a key word would afford, by writing in cipher,
sufficient secrecy.
In the course of this debate much wit was displayed in speaking
on different modes of keeping secrets, and the futility of all; with
allusions to the secret proceedings of Congress, particularly those
which took place on the 19th instant, which were said to have been
known before the House took them up. Some amusement also arose
amongst the members from the difficulty of hearing each other, and
the consequent mistakes that took place.
The question on concurrence being taken was carried, 50 to 48.
The committee rose and reported to the House their agreement to
the resolution contained therein; which was read, as follows:

Resolved, That it shall be lawful for the President of the United


States to obtain, by purchase, at a reasonable price, the exclusive
right, on behalf of the public, of the system invented by Sir James
Jay, as submitted by him to the Executive Department of
Government: provided, in the opinion of the President, it will be of
public utility and importance to possess the same.

The House proceeded to consider the said resolution; and, on the


question that the House do concur with the Committee of the whole
House in their agreement to the same, Messrs. J. Clay and Southard
opposed, and Messrs. Sloan, Quincy, Newton, Blackledge, and
Crowninshield, supported it. The question was then taken, and
decided in the affirmative—yeas 74, nays 53.

Tuesday, November 24.


British Aggressions.

Mr. Blount, from the committee appointed on so much of the


Message of the President of the United States as relates to
aggressions committed within our ports and waters by foreign armed
vessels; to violations of our jurisdiction; and to measures necessary
for the protection of our ports and harbors; presented to the House
a letter from the Secretary of the Navy, stating that, in a letter
addressed by him, on the twelfth instant, to the chairman of the said
committee, some erroneous information had been given, and an
omission made, which he had since discovered, and thought it his
duty now to correct. The said letter was read, and ordered to lie on
the table.
Mr. Blount, from the committee to whom was referred so much of
the Message of the President of the United States as relates to
aggressions, &c., reported further, in part,

“That the numerous aggressions and violations of our jurisdiction


recently committed within our ports and waters by British ships of
war, whether they are to be regarded as the effects of positive
orders from the British Government, or as proceeding from that
unrestrained insolence and rapacity in British naval commanders
which previously produced the murder of our fellow-citizen, Pierce,
and the perpetration of many other well-remembered outrages and
irritating acts, are convincing proofs of the necessity of placing our
ports and harbors, as speedily as possible, in a situation to protect
from insult and injury the persons and property of our citizens living
in our seaport towns, or sailing in our own waters, and to preserve
therein the respect due to the constituted authorities of the nation.
“That the committee, having maturely considered the subject, are
of opinion that the protection desired can be best and most
expediously afforded by means of land batteries and gunboats, as
they have been induced to believe that by a judicious combination
and use of these two powers, effectual protection can be given,
even to our most important seaport towns, against ships of any size
unaccompanied by an army.
“That our most important ports and harbors, and those requiring
the earliest attention and the most expensive fortifications, are, New
Orleans, Savannah, Charleston, S. C., Wilmington, N. C., Norfolk,
Baltimore, Philadelphia, New York, New London, Newport, R. I.,
Boston, Salem, Newburyport, Portsmouth, N. H., and Portland.
“And that the ports, harbors, and places of minor importance
requiring protection, and which may be protected by less expensive
works, are, St. Mary’s, Ga., Beaufort, and Georgetown, S. C.,
Ocracoke, Albemarle Sound, James River, York, and Rappahannock
Rivers, Potomac, Patuxent, Annapolis, and Eastern Shore, Md.,
Delaware Bay and River, Egg Harbor, N. J., Amboy, Long Island,
Connecticut shore, Tiverton, R. I., New Bedford, Marblehead, and
Cape Ann, York, Kennebunk, and Saco, Kennebeck, Sheepscut,
Damarescotta, Broad Bay, and St. Georges, Penobscot, Frenchman’s
Bay, and Passamaquoddy Bay.
“Wherefore, your committee holding themselves bound, by the
tenor of the resolution referred to them, to report hereafter their
opinion of the expediency of interdicting the waters of the United
States to foreign armed vessels, according as circumstances, now
unknown, may, when known, seem to require, submit the following
resolutions, viz:
“Resolved, That it is expedient to authorize the President of the
United States to cause such fortifications to be erected as, in
addition to those heretofore built, will, with the assistance of
gunboats, afford effectual protection to our ports and harbors, and
preserve therein the respect due to the constituted authorities of the
nation; and that there be, and hereby is, appropriated for that
purpose, out of any moneys in the Treasury not otherwise
appropriated, the sum of —— dollars.
“Resolved, That it is expedient to authorize the President of the
United States to cause to be built an additional number of gunboats
not exceeding ——, and to arm, equip, man, fit, and employ the
same for the protection of our ports and harbors; and that there be,
and hereby is, appropriated for that purpose, out of any moneys in
the Treasury not otherwise appropriated, the sum of ——.”

The report was referred to a Committee of the Whole on


Thursday.

Tuesday, December 1.
Mr. Quincy offered the following resolution:
Resolved, That the Secretary of the Department of War be
directed to lay before this House an account of the state of the
fortifications of the respective ports and harbors of the United
States, with a statement of the moneys appropriated for
fortifications remaining unexpended; and an estimate of the sums
necessary for completing such fortifications as may be deemed
requisite for their defence.

Which being under consideration,


Mr. Q. said the House would perceive the object of this resolution
was to obtain information; there was a document on their table
which gave some information on the subject, but was not explicit.
This resolution was exactly similar to one passed last session, by
which the House obtained some important and interesting
information; this being the case, he hoped no objection would be
made to it.
The resolution was agreed to without a division.

Soldiers of the Revolution, &c.

Mr. Randolph rose and said, that as long as the subject of national
defence was in possession of a respectable committee of the House,
and as long as their report was pending before it, he had deemed it,
if not improper, at least unavailing in him, to offer any thing upon
that subject. But, that committee having reported, he saw, from the
course which the debate had taken yesterday, a necessity so
pressing that he could no longer dispense with it, for offering some
propositions on this most important subject. These propositions
grew out of the almost universal impression which seemed to exist
that there was but one peculiar mode of defence to which the nation
could turn itself in this perilous juncture of their affairs. When so
great an appropriation was demanded for this favorite expedient, he
feared, that if other plans of defence, which had at least as high
claims to the public attention, were not now brought forward, they
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like