//TODO: professional stuff of software engineer 1001010
Swift: prefix/postfix ‘=’ is reserved

Neat – Apple released x-code 6 beta for free! Which means I finally got a chance to try swift in the “playground”.

As I go through the book and teach myself all about this shiny new tech bauble I may comment on it here.

OH LOOK, a scuff mark already

Playground looks interesting, but where’s the “run” button?  The book tells me to try “println("Hello World")” – but I can’t figure out how to launch it.  Oh well, I don’t care that much.  It looks like it’s real value is a teaching environment to play with code structures & simple flow – sort of like a code calculator.

First “code” section: “Simple Values”

var myVariable = 42

myVariable = 50
let myConstant = 42

Excerpt From: Apple Inc. “The Swift Programming Language.” iBooks. https://itun.es/us/jEUH0.l

That’s great – but I’m a terrible typist.  I ended up typing “var myVariable= 42”  And it errored.  WTF?

Swift irregular spaces around equal sign

As you can see, “x = y” and “x=y” are valid, but “x= y” and “x =y” are not.

W. T. F. ?

This.. is a new problem for me. In my experiences with C languages or Python, I’m not accustomed to casual compiler problems with spaces around an equal sign.  Looking at the error, there are a few things going through my head.

  1. The lexer is borked – it’s a new language after all, so not too unexpected
  2. Whitespace has meaning?  Yes, there are times where whitespace removes confusion in code.  Say in C++ where you have a template containing template params: std::map<int, std::vector<int>> needs to be std::map<int, std::vector> >” – but that’s a lexing issue.
  3. Someone is a fan of The Whitespace Programming Language
    It’s still early in the book – I hope they’re not a fan of brainfuck as well 🙁
  4. OK.. Let’s check the book

Damn it.  It’s in the book.  Here’s the relevant section..

Operators are made up of one or more of the following characters: /, =, -, +, !, *, %, <, >, &, |, ^, ~, and .. That said, the tokens =, ->, //, /*, */, ., and the unary prefix operator & are reserved. These tokens can’t be overloaded, nor can they be used to define custom operators.

The whitespace around an operator is used to determine whether an operator is used as a prefix operator, a postfix operator, or a binary operator. This behavior is summarized in the following rules:

If an operator has whitespace around both sides or around neither side, it is treated as a binary operator. As an example, the + operator in a+b and a + b is treated as a binary operator.
If an operator has whitespace on the left side only, it is treated as a prefix unary operator. As an example, the ++ operator in a ++b is treated as a prefix unary operator.
If an operator has whitespace on the right side only, it is treated as a postfix unary operator. As an example, the ++ operator in a++ b is treated as a postfix unary operator.
If an operator has no whitespace on the left but is followed immediately by a dot (.), it is treated as a postfix unary operator. As an[…]

Excerpt From: Apple Inc. “The Swift Programming Language.” iBooks. https://itun.es/us/jEUH0.l

Matching space count and it’s a binary operator?  FOR EQUAL?

Space on one side only and it’s a PREFIX/POSTFIX UNARY OPERATOR?  FOR EQUAL?

 

Two pages in & two issues.  Maybe this is a journey into Brainfuck

 

-Jason De Arte

Creepy LinkedIn Recruiter …

… just because I clicked on your profile, it does not mean that I am interested in what you are selling. It just means I’ve got fat fingers or are curious to learn through which connection we know each other. Telling me that you noticed me viewing your profile 3 minutes ago, makes you sound like a creepy stalker. Yes, I know stalkers are by definition “creepy” – but it needed to be emphasized in your case.

 

-Jason De Arte

New year; new theme

It’s quite a bit less busy than the old theme – which I like.  But it has this un-natural lust for all upper case titles that I could do without.  But it’s free and it’s close enough for my needs.

I’m playing with the idea of not having a page/site title/tag at the top of the page.  To have it there in big bold text always felt.. imposing.  Maybe I’ll put it back after I tweak the CSS to make it a bit smaller/subtle.

-Jason De Arte

Remember CodeProject?

I forgot all about it too.  It’s still there, I even have a bit of sample code on their site.  Long-long ago I wrote a /delayload replacement because it was the cool thing to do. At the time it was the best spot to find Win32 code examples other than MSDN.  CodeProject did a decent job answering that core software engineer need for it’s readers: “How do I implement X?”.

Looking back I see that it was backwards.  It was an article/publisher model that relied on people to create the answers to the questions people might be seeking before the questions were answered.  Since psychic powers are in short supply among the technically minded, the reach will always be limited.

Today we have a better answer: StackOverflow.  Instead of waiting for someone to write an answer to the unwritten question, we have a place where we can write the actual question and (if it’s well written & not a plea from someone stuck on their CS homework) get quality answers.

Now the cool geek thing to do is to be the one that writes the best upvoted answers on StackOverflow. For a few of my co-workers, they’ve made a sport* of writing quality answers before anyone else.  It’s sort of like doing Project Euler problems on hard mode.

-Jason De Arte

*I know, a sport involves a ball. whatever

FOASS on GitHub

Experimentation time!  I created a GitHub account and put the two file source to http://foass.1001010.com on it.

Why? Because I can.

I created my FOAAS clone to learn how to create a stateless web service in Python.  Maybe someone else wants to learn how to and they just need an example on how to do it.

OK – maybe my example is not the best one, but it works – and I got to play with the GitHub Windows client.  I wonder what the OSX one is like & how well pyCharm integrates with it?

-Jason De Arte

Previous Page · Next Page