Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "emit" mean in general computer science terms?

Tags:

I just stumbled on what appears to be a generally-known compsci keyword, "emit". But I can't find any clear definition of it in general computer science terms, nor a specific definition of an "emit()" function or keyword in any specific programming language.

I found it here, reading up on MapReduce:

https://en.wikipedia.org/wiki/MapReduce

The context of my additional searches show it has something to do with signaling and/or events. But it seems like it is just assumed that the reader will know what "emit" is and does. For example, this article on MapReduce patterns:

https://highlyscalable.wordpress.com/2012/02/01/mapreduce-patterns/

There's no mention of what "emit" is actually doing, there are only calls to it. It must be different from other forms of returning data, though, such as "return" or simply "printf" or the equivalent, else the calls to "emit" would be calls to "return".

Further searching, I found a bunch of times that some pseudocode form of "emit" appears in the context of MapReduce. And in Node.js. And in Qt. But that's about it.

Context: I'm a (mostly) self-taught web programmer and system administrator. I'm sure this question is covered in compsci 101 (or 201?) but I didn't take that course.

like image 357
JDS Avatar asked Jul 07 '15 13:07

JDS


1 Answers

I've only ever seen emit() used when building a simple compiler in academia.

Upon analyzing the grammar of a program, you tokenize the contents of it and emit (push out) assembly instructions. (The compiler program that was written actually even contained an internal function called emit to mirror that theoretical/logical aspect of it.)

Once the grammar analysis is complete, the assembler will take the assembly instructions and generate the binary code (aka machine code).

So, I don't think there is a general CS definition for emit; however, I do know it is used in the pseudocode (and sometimes, actual code) for writing compiler programs. And that is undergraduate level computer science education in the US.

like image 197
ryuu9187 Avatar answered Sep 23 '22 17:09

ryuu9187