-1

What is fexpr in PHP? As I caught so far, It is a kinda function in Lisp language:

In Lisp programming languages, a fexpr is a function whose operands are passed to it without being evaluated.

I was reading an article which had deeply discussed PHP constructs, I faced fexpr there & Googling led me into the fact that it is fundamentally a Lisp concept!

That's why I can't clearly wrap my head around. Would you mind explain what fexpr is in PHP? and (if its semantically conceivable) Please provide an example & Use Case.

behkod
  • 2,647
  • 2
  • 18
  • 33
  • Did you have a link to the discussion you read? – JustOnUnderMillions Mar 10 '17 at 15:00
  • A will make a asumtion for `fexpr is in PHP`: It maybe is relevant when php-code is compiled to opcode. But that is not in your workspace so you can ignore it. There is no real syntax in php that can evaluate `fexpr` – JustOnUnderMillions Mar 10 '17 at 15:11
  • @JustOnUnderMillions Here in SO. under "Is `print` a function?" – behkod Mar 10 '17 at 15:21
  • Ok, know i now what going on, but its little hard to explain. Its all about syntax and what and how is done. For the echo vs print thing i know that you can do `$value AND print $value` because print return 1, echo does not and must be written in this form `if($value){ echo $value;}`. But i still thing you can ignore it. There is almost no need to thing about it. Use of references in php is more interisting and important. – JustOnUnderMillions Mar 10 '17 at 15:29
  • Also this statement is little false: `Why do print(1,2,3) and echo(1,2,3) result in syntax errors?` This works `echo 1,2,3,4,$r=5;` this not `print 1,2,3,4;`. And if you wrap `()` it like `echo (1,2,3,4,$r=5;)` php trys to evaluate the content in `()` but that wont work because it is no real exper with `+ / * -`. But `echo (1+1);` and `echo (1);` will work. – JustOnUnderMillions Mar 10 '17 at 15:34
  • And finaly that they talk about `Speed: echo x vs print x` is very offtopic. micro-benchmarking at its best. – JustOnUnderMillions Mar 10 '17 at 15:36
  • It's not safe to assume that the same word used in different contexts refer to the same thing in both cases. – molbdnilo Mar 10 '17 at 18:04

1 Answers1

2

Simply put - it's the thing that enables "functions" like isset() and empty() to accept possibly undefined variables.

That's only possible because they aren't actually functions, but language keywords (try declaring classes with those names, it won't work) recognized by the parser and then executed by the compiler. A regular function is executed at runtime.

If that doesn't answer your question, then you'd first need to understand what compilers and runtimes are ... I'm afraid that's too broad to explain here.

Other than that, I don't know Lisp, but I can only assume that "fexpr" is a prominent feature in that language. As in, you could possibly declare your own fexpr-essions - PHP doesn't have this; it just utilizes the concept for a few special cases.

Narf
  • 14,600
  • 3
  • 37
  • 66