JoshOrndorff / LearnRholangByExample

Teaches rholang to beginners and intermediate programmers through hands-on examples and experimentation.
67 stars 32 forks source link

Add clarity to 'Quoting and Unquoting' #16

Closed glenbraun closed 6 years ago

glenbraun commented 6 years ago

Sorry if this is just me, but I don't get the meaning of the content under 'Quoting and Unquoting'. What do the '/' slashes mean? Is this markdown that isn't being interpreted, or character-based art?

Quoting and Unquoting "Send processes, receive names" --@-- Process / /
Name <---*--

I like the "send processes, receive names" but does that mean when you send something it must be a process. This doesn't seem right. Does it really mean that you send on processes but when you get what comes over them it is a name? @"Foo"!("hello"), seems like @"Foo" is a process. Or is that not right "Foo" is a process and @ makes it a name you can send on? And then, when you receive on @"Foo" you get something that is a name? (but then you can put "for (@x <- @"Foo")" to make it a process? Totally confusing. Everyone else seems to get it, but I just add a @ or a * until it works. It would be awesome to really understand. Also there is a thing called a name-variable, and a process-variable. So, one could have just an 'x' but it is a process variable (no @ sign in front) but also a name 'x' that is a name-variable. This further confuses (I think. if I'm even right about name and process variables).

JoshOrndorff commented 6 years ago

The slashes and whatnot are my shitty ascii version of the arrows in the whiteboard photo above :)

Correct: "send processes, receive names" Incorrect: "send on processes, receive on names"

You always send and receive on names. But the thing which you send must be a process, and the thing you receive on the other end is the quote of the sent process, which is a name.

Or is that not right "Foo" is a process and @ makes it a name you can send on?

Correct

And then, when you receive on @"Foo" you get something that is a name?

Correct; You always receive names.

(but then you can put "for (@x <- @"Foo")" to make it a process? Totally confusing.

The thing you received is still a name. You always receive names. The difference is that you used pattern matching so that the name you received matches @x thus x itself is a process. Here's the relevant part of the tutorial https://github.com/JoshOrndorff/LearnRholangByExample/tree/master/10-MoreSyntax#receiving-processes

Also there is a thing called a name-variable, and a process-variable.

Correct

So, one could have just an 'x' but it is a process variable (no @ sign in front) but also a name 'x' that is a name-variable. This further confuses

Variable names don't reflect their types. Just like in java int x = 4; is perfectly valid and double x = 3.2; is perfectly valid. What you call the variable doesn't indicate anything about its type.

You should come to my office hours Thursday mornings at 7:00am your time. I'll be expecting you :)

JoshOrndorff commented 6 years ago

The poor dude whose github handle is @x probably gets tagged in a bunch of rholang related posts.

Maybe I should start writing all of my example receives as for (@glenbraun <- badassProgrammers){...}

BTW, that would make glenbraun a process variable.

glenbraun commented 6 years ago

But, then one can do:

new foo in { … }, which seems to create a name called "foo". When one does: for (foo <- bar) { } both foo and bar are names? but: for (@foo <- bar) makes foo a process? Is foo a name variable in the first and a process variable in the second? or the other way around? Are the three letters 'f' then 'o', then 'o' a name variable, but the syntax '@' makes it a process variable? or the other way around. I guess I'm being thick but it makes no sense to me. I get it a little that what can be put into the RSpace are processes that are quoted, rather than names. The name is the key, the quoted process is the value. Best, I know. It will likely make sense for me someday, but I have to think there must be some other programmer out there who will try to learn Rholang who has a similar issue. It seems the description needs some better way to describe it. I think the usage seems to depend on context, whether one is receiving or sending (maybe, I don't know). Anyway, will keep at it and see if it becomes more clear over time.