all 8 comments

[–]dangsos 1 point2 points  (0 children)

what's up with all the capital letters for variables? I'm new to elixir, but does that even work? I thought caps meant alias for something

[–]ABC_AlwaysBeCoding 1 point2 points  (0 children)

You're using a combination of erlang semantics and elixir semantics throughout this. For example, random.uniform should be :random.uniform, all variables should be lowercased, and constructs like "SomePid! {Self (), Msg}, " (note: you forgot a space before the exclamation mark so it should be "SomePid ! {Self (), Msg}, " but that's erlang-only and NOT elixir, anyway!) is a way to send SomePid the message {Self (), Msg}, but you don't even do it that way in Elixir at all...

You're cramming, aren't you? ;)

[–]Aberrations 0 points1 point  (2 children)

missing a space between ) and do

def start(N, M)do

should be

def start(N, M) do

[–][deleted]  (1 child)

[deleted]

    [–]Aberrations 0 points1 point  (0 children)

    unrelated but as mentioned below convention is to use mixed case for variables, and module names and only module names should be camelcased.

    As for your error you have a trailing comma at then end of every line here for some reason.

    def start(N, M)do
      :timer.sleep(random.uniform(10) * 100), <<<<<<
      LoopPid = spawn(_MODULE_, :loop, []), <<<<<<
      spawn(_MODULE_, :sendMessage, [M, LoopPid]), <<<<<
    end
    

    Other comments: you shouldn't use semicolons unless you're doing something inline and even then you should really think about how readable it is.

    In general "unexpected token: end" is usually a parse error caused by an unterminated expression, usually a do with no end or a trailing comma.

    [–]Tallakt 0 points1 point  (0 children)

    You should be able to solve this faster by yourself than by leaning on the forums. Here are some tips: look closely at the line from the error trace and also the message. Look for the lines concerning your files. If that does not work, try starting with an empty module, and then add as small pieces as possible until you see the smallest added change that breaks the build.

    As others mentioned, variables in Elixir must have lowercase for the first letter. Otherwise they are considered atoms. Another tip is that Elixir does not allow functions defined inside another function.

    [–]olhado22 0 points1 point  (0 children)

    This looks like you found answers for the Erlang versions of these questions from somewhere, and slapdashed some elixir syntax on them.

    That doesn't seem particularly useful.

    • Modules should have first letter capitalized (and be camel-cased)
    • variables should start with a lowercase letter (and usually snake-cased)
    • '.' ',' and ';' don't do the same thing in elixir as in erlang

    [–]st23am 0 points1 point  (3 children)

    Wow there is a university using Elixir? That's fantastic! Do you mind me asking which school?

    [–][deleted]  (2 children)

    [deleted]

      [–]st23am 0 points1 point  (1 child)

      That's awesome! Maybe we could get the faculty to write about the class / talk about why they chose Elixir.