Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

Prefix/polish notation in Java

Name: Anonymous 2009-02-08 12:09

How do I do it?????????

Name: Anonymous 2009-02-08 12:09

Read SICP.

Name: Anonymous 2009-02-08 12:10

With prudence. Who knows what might happen to you.

Name: Anonymous 2009-02-08 12:13


arg1 op arg2 = (op) arg1 arg2
op arg1 arg2 = arg1 `op` arg2


And that's why the haskell faggots keep writing 11 `div` 3. What the fuck. What's wrong with the prefix notation. Haven't they read their SICP?

Name: Anonymous 2009-02-08 12:35

3 `+` 4

Name: Anonymous 2009-02-08 12:36

my `hax` anus

Name: Anonymous 2009-02-08 12:55

>>5,6
That's wrong.

Name: Anonymous 2009-02-08 12:57

`(div)` 11 3

Name: Anonymous 2009-02-08 13:00

Function application is Java already uses prefix notation. It just happens to wrap the arguments in parentheses for no discernible reason.
And for some reason, it doesn't think operators are functions.

Name: Anonymous 2009-02-08 13:01

>>9
And for some reason, it doesn't think operators are functions.
Java's not Scheme, where everything is a function.

Name: Anonymous 2009-02-08 13:43

>>10
Scheme's not Lambda Calculus, where everything is a function.

Name: Anonymous 2009-02-08 16:55

Prefix is for faggots, it's all about postfix.

Name: Anonymous 2009-02-08 16:57

>>12
It doesn't matter as long as it's consistent.

Name: Anonymous 2009-02-09 7:35

>>12
Postfix sucks:
- Variable arguments are needlessly complicated
- Practically requires a stack-based implementation, so it's more difficult to optimize code on typical systems
- Common constructs ('if', 'loop') either need to be written backwards (unintuitive), or require extra syntactic sugar or special cases in the parser (inflexible)
- Determining whether a given token is a function call or variable requires either a lookup table or extra syntax
- Program errors that disrupt the stack are easy to make and difficult to diagnose

With prefix notation, the only syntax necessary is a statement delimiter. This is a more than acceptable tradeoff for the tremendous gain in language flexibility, parsing is dead simple, because the first token in any given expression will always be either a function or a subexpression that resolves to one, and following tokens until the closing delimiter are its arguments.

Name: Anonymous 2009-02-09 8:39

>>14
Practically requires a stack-based implementation
Only if you allow functions with a variable number of input or output values. Which isn't really useful anyway (see your first point).

special cases in the parser (inflexible)
Unless you have parser macros. But I agree with the sentiment.

Determining whether a given token is a function call or variable requires either a lookup table or extra syntax
Variables and constants are conceptually functions that take nothing and return one value. E.g. in Factor:
( scratchpad ) [ 1 ] infer.
( -- object )


Program errors that disrupt the stack are easy to make and difficult to diagnose
Which is why you use a type system that helps you with that.


Anyway, I'm a Schemer because λ > SKI and naming things is the greatest thing ever.

Name: Anonymous 2009-02-09 9:34

>>15
Only if you allow functions with a variable number of input or output values. Which isn't really useful anyway (see your first point).
(+ 1 2 3 4 5) etc. isn't useful?

a type system
Now you have two problems.

Name: Anonymous 2009-02-09 10:13

I kinda like programming in RPL on my old trusty HP48GX, 4 bit crap and all...

Name: Anonymous 2009-02-09 10:26

>>16
(+ 1 2 3 4 5) etc. isn't useful?
It just doesn't fit the implicit argument passing paradigm. So it isn't useful in that context. The stack giveth and the stack taketh away.

Name: Anonymous 2009-02-09 15:10

(+ 1 2 3 4 5) etc. isn't useful?
{ 1 2 3 4 5 } sum is really that much more difficult?

Name: Anonymous 2009-02-09 18:41

Infix ftw XD

Name: Anonymous 2009-02-09 18:46

(+ 1 (+ 2(+ 3(+ 4 5))))

LOOKS LIKE SHIT, NO?

Name: Anonymous 2009-02-09 19:00

>>21
wow, that looks even worse than 1 2 + 3 + 4 + 5 +...

Name: Anonymous 2009-02-09 19:14

>>21
The reason prefix notation was created was to be unambiguous and not need parentheses...
+ 1 + 2 + 3 + 4 5

Name: Anonymous 2009-02-09 19:24

>>23
no, the reason prefix notation was created was to do things backwards.

Name: Anonymous 2009-02-10 3:22

>>21
pig disgusting

Name: Anonymous 2009-02-10 3:29

>>21
EXPERT BUTT-UGLY

Name: Anonymous 2009-02-10 12:44

PREFIX IS THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST, THE BEST

Name: Anonymous 2009-02-10 15:21

>>27
[DESU ..]

Name: Anonymous 2009-02-10 22:05

>>28
map (\_ -> "DESU") [1..]

Name: Anonymous 2009-02-10 22:26

>>29
data FrostedButts = TheBest | DESU
        deriving (Eq, Show)

cycle [DESU]

Name: Anonymous 2009-02-10 22:34

The pleasure of SICP inside

Name: Anonymous 2009-02-10 22:38

>>30

data ForcedMemes = TheBest
                 | DESU
                 deriving (Eq, Show, Ord)

main = do
  print $ DESU > TheBest      -- True

Name: Anonymous 2009-02-10 22:42

>>29
repeat "DESU"

Name: Anonymous 2009-02-10 23:05

>>33
You forgot unwords. HOW COULD YOU FORGET UNWORDS?

Name: Anonymous 2009-02-10 23:14

>>34
why the fuck would  you use unwords?

Name: Anonymous 2009-02-10 23:19

>>35
Prelude> repeat "DESU"
["DESU","DESU","DESU","DESU","DESU","DESU","DESU","DESU","DESU","DESU","DESU","DESU","DESU","DESU","DESU","DESU","DESU", ...]
Prelude> unwords $ repeat "DESU"
"DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU..."
Prelude> error "I think I've made my point."
** Exception: OH SHI-

Name: Anonymous 2009-02-10 23:49

>>36
Could you explain what you just did?
I don't know any programming language so there.

Name: Anonymous 2009-02-10 23:55

>>37
Do you know the diff between a string and a list of strings?

Name: Anonymous 2009-02-11 0:05

>>36
compare:
mapM_ putStr $ repeat "DESU"
vs.
putStr . unwords $ repeat "DESU"

Name: Anonymous 2009-02-11 0:16

>>39
Second version considered more pure.

Name: Anonymous 2009-02-11 0:27

for(;;)
   System.Out.Print("Desu ");

Name: Anonymous 2009-02-11 1:03

mapM_ putStr $ repeat "DESU "
fixed.

Name: Anonymous 2009-02-11 12:18

putStr $ cycle "DESU "
fixed.

Name: Anonymous 2009-02-11 12:19

putStr $ cycle "DESU "

Name: Anonymous 2009-02-11 14:15

>>38
not really.
:(

Name: Anonymous 2009-02-11 17:41

język polski, polszczyzna

Name: Anonymous 2009-02-11 17:43

Urodził się w spolszczonej i od trzech pokoleń osiadłej w Brzeżanach, a wcześniej w Stryju, rodzinie urzędnika skarbowego - Aleksandra Mariana Brücknera.

Name: Anonymous 2009-02-11 17:48

>>46
>>47
back to /poland/ please

Name: Anonymous 2009-02-25 8:05


Characters char string char   removeMe int i   X Y where   X depends on   project size If.

Name: Anonymous 2010-11-13 12:40

Don't change these.
Name: Email:
Entire Thread Thread List